#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "iconhelper.h"
#include <QHostInfo>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->initForm();
    this->initLeftMain();
    this->initLeftConfig();
    CustomBar_car();
    CustomBar_dg();
    CustomBar_sys();
    CustomBar_System();
    CustomBar_nb1();
    CustomBar_nb2();
    CustomBar_nb3();
    CustomBar_nbtem();
    CustomBar_nbW();
    CustomBar_DC();
    CustomBar_Charge();
    CustomBar_JS();
    CustomBar_Js_Sys();
    CustomBar_DG();
    CustomBar_Bug();
    InitTableDG();
    InitTableBug();

/****************************** TCP线程 *****************************/
    serverCar = new Server();
    connect(serverCar,&Server::SIGCon,this,&MainWindow::TCPCar);
    connect(serverCar,&Server::SIGDC1_1,this,&MainWindow::DCDC1DATA);
    connect(serverCar,&Server::SIGDC1_2,this,&MainWindow::DCDC1DATA);
    connect(serverCar,&Server::SIGRs4851,this,&MainWindow::LocationView);
    connect(serverCar,&Server::SIGRs4852,this,&MainWindow::CarTemView);
    //导轨TCP服务端
    tcpServer1 = new QTcpServer(this);
    tcpServer2 = new QTcpServer(this);
    tcpServer3 = new QTcpServer(this);
    tcpServer4 = new QTcpServer(this);
    tcpServer5 = new QTcpServer(this);
    tcpServer6 = new QTcpServer(this);
    tcpServer7 = new QTcpServer(this);
    tcpServer8 = new QTcpServer(this);
    tcpServer9 = new QTcpServer(this);
    connect(this,&MainWindow::tcpcon,this,&MainWindow::TCPDG);
    connect(this,&MainWindow::sig_track1Data,this,&MainWindow::DG1View);
    //导轨TCP连接函数
    tcpServer1->listen(QHostAddress::Any,8801);
    connect(tcpServer1,SIGNAL(newConnection()),this,SLOT(mNewConnection1()));
    tcpServer2->listen(QHostAddress::Any,8802);
    connect(tcpServer2,SIGNAL(newConnection()),this,SLOT(mNewConnection2()));
    tcpServer3->listen(QHostAddress::Any,8803);
    connect(tcpServer3,SIGNAL(newConnection()),this,SLOT(mNewConnection3()));
    tcpServer4->listen(QHostAddress::Any,8804);
    connect(tcpServer4,SIGNAL(newConnection()),this,SLOT(mNewConnection4()));
    tcpServer5->listen(QHostAddress::Any,8805);
    connect(tcpServer5,SIGNAL(newConnection()),this,SLOT(mNewConnection5()));
    tcpServer6->listen(QHostAddress::Any,8806);
    connect(tcpServer6,SIGNAL(newConnection()),this,SLOT(mNewConnection6()));
    tcpServer7->listen(QHostAddress::Any,8807);
    connect(tcpServer7,SIGNAL(newConnection()),this,SLOT(mNewConnection7()));
    tcpServer8->listen(QHostAddress::Any,8808);
    connect(tcpServer8,SIGNAL(newConnection()),this,SLOT(mNewConnection8()));
    tcpServer9->listen(QHostAddress::Any,8809);
    connect(tcpServer9,SIGNAL(newConnection()),this,SLOT(mNewConnection9()));
    //定时发送函数
    m_timer1=new QTimer(this);
    m_timer1->setInterval(50);//间隔50毫秒
    connect(m_timer1,SIGNAL(timeout()),this,SLOT(sendDataQ1()));
    h_timer1=new QTimer(this);
    h_timer1->setInterval(500);//间隔500毫秒
    connect(h_timer1,SIGNAL(timeout()),this,SLOT(doheart1()));
    m_timer2=new QTimer(this);
    m_timer2->setInterval(50);//间隔50毫秒
    connect(m_timer2,SIGNAL(timeout()),this,SLOT(sendDataQ2()));
    h_timer2=new QTimer(this);
    h_timer2->setInterval(500);//间隔500毫秒
    connect(h_timer2,SIGNAL(timeout()),this,SLOT(doheart2()));
    m_timer3=new QTimer(this);
    m_timer3->setInterval(50);//间隔50毫秒
    connect(m_timer3,SIGNAL(timeout()),this,SLOT(sendDataQ3()));
    h_timer3=new QTimer(this);
    h_timer3->setInterval(500);//间隔500毫秒
    connect(h_timer3,SIGNAL(timeout()),this,SLOT(doheart3()));
    m_timer4=new QTimer(this);
    m_timer4->setInterval(50);//间隔50毫秒
    connect(m_timer4,SIGNAL(timeout()),this,SLOT(sendDataQ4()));
    h_timer4=new QTimer(this);
    h_timer4->setInterval(500);//间隔500毫秒
    connect(h_timer4,SIGNAL(timeout()),this,SLOT(doheart4()));
    m_timer5=new QTimer(this);
    m_timer5->setInterval(50);//间隔50毫秒
    connect(m_timer5,SIGNAL(timeout()),this,SLOT(sendDataQ5()));
    h_timer5=new QTimer(this);
    h_timer5->setInterval(500);//间隔500毫秒
    connect(h_timer5,SIGNAL(timeout()),this,SLOT(doheart5()));
    m_timer6=new QTimer(this);
    m_timer6->setInterval(50);//间隔50毫秒
    connect(m_timer6,SIGNAL(timeout()),this,SLOT(sendDataQ6()));
    h_timer6=new QTimer(this);
    h_timer6->setInterval(500);//间隔500毫秒
    connect(h_timer6,SIGNAL(timeout()),this,SLOT(doheart6()));
    m_timer7=new QTimer(this);
    m_timer7->setInterval(50);//间隔50毫秒
    connect(m_timer7,SIGNAL(timeout()),this,SLOT(sendDataQ7()));
    h_timer7=new QTimer(this);
    h_timer7->setInterval(500);//间隔500毫秒
    connect(h_timer7,SIGNAL(timeout()),this,SLOT(doheart7()));
    m_timer8=new QTimer(this);
    m_timer8->setInterval(50);//间隔50毫秒
    connect(m_timer8,SIGNAL(timeout()),this,SLOT(sendDataQ8()));
    h_timer8=new QTimer(this);
    h_timer8->setInterval(500);//间隔500毫秒
    connect(h_timer8,SIGNAL(timeout()),this,SLOT(doheart8()));
    m_timer9=new QTimer(this);
    m_timer9->setInterval(50);//间隔50毫秒
    connect(m_timer9,SIGNAL(timeout()),this,SLOT(sendDataQ9()));
    h_timer9=new QTimer(this);
    h_timer9->setInterval(500);//间隔500毫秒
    connect(h_timer9,SIGNAL(timeout()),this,SLOT(doheart9()));

    conform = new ControlForm();

    refreshTimer = startTimer(100, Qt::CoarseTimer);
    sampleTimer = startTimer(100, Qt::CoarseTimer);

    on_btnMenu_Max_clicked();
}

MainWindow::~MainWindow()
{
    delete ui;
}

QString MainWindow::getLocalIP()
{
    QString ipString = Q_NULLPTR;
    QHostInfo hostInfo = QHostInfo::fromName(QHostInfo::localHostName());   //从本地主机名称获取主机信息
    QList<QHostAddress> listAddr = hostInfo.addresses();    //本地主机ip地址列表(IPV4/IPV6)
    foreach (auto addr, listAddr)
    {
        if((addr.isNull() == false) && (addr.protocol() == QAbstractSocket::IPv4Protocol)
                && (addr != QHostAddress::LocalHost))
        {
            ipString = addr.toString();   //根据条件筛选出本地IPV4地址
        }
    }
    return ipString;
}

QByteArray MainWindow::hexStringToByteArray(QString HexString)
{
    bool ok;
    QByteArray ret;
    HexString = HexString.trimmed();
    HexString = HexString.simplified();
    QStringList sl = HexString.split(" ");

    foreach (QString s, sl)
    {
        if(!s.isEmpty())
        {
            char c = static_cast<char>(s.toInt(&ok, 16) & 0xFF);
            if(ok)
            {
                ret.append(c);
            }
            else
            {
                qDebug()<<"error:"<<s;

            }
        }
    }
    return ret;
}

quint16 MainWindow::calculateCRC16(const QByteArray &data)
{
    const quint16 polynomial = 0xA001;
    quint16 crc = 0xFFFF;

    for (int i = 0; i < data.length(); i++) {
        crc ^= (quint16)data.at(i) & 0xFF;
        for (int j = 0; j < 8; j++) {
            if (crc & 0x0001) {
                crc = (crc >> 1) ^ polynomial;
            } else {
                crc >>= 1;
            }
        }
    }
    return crc;
}

void MainWindow::timerEvent(QTimerEvent *event)
{
    Q_UNUSED(event);

    double key = QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0;

    if(event->timerId() == refreshTimer)
    {
        double xHigh = key - 0.5;
        ui->plot_Sys->xAxis->setRange(xHigh - ui->plot_Sys->xAxis->range().size(),xHigh);
        ui->plot_Sys->replot();
        ui->plot_nb1->xAxis->setRange(xHigh - ui->plot_nb1->xAxis->range().size(),xHigh);
        ui->plot_nb1->replot();
        ui->plot_nb2->xAxis->setRange(xHigh - ui->plot_nb2->xAxis->range().size(),xHigh);
        ui->plot_nb2->replot();
        ui->plot_nb3->xAxis->setRange(xHigh - ui->plot_nb3->xAxis->range().size(),xHigh);
        ui->plot_nb3->replot();
        ui->plot_nbW->xAxis->setRange(xHigh - ui->plot_nb3->xAxis->range().size(),xHigh);
        ui->plot_nbW->replot();
    }
    if(event->timerId() == sampleTimer) //30ms
    {
        int min = 20;
        int max = 100;
        int a = rand()%(max-min)+min;
        int b = rand()%(max-min)+min;
        int c = rand()%(max-min)+min;
        ui->plot_Sys->graph(0)->addData(key, a);
        ui->plot_Sys->graph(1)->addData(key, b);        
        ui->plot_nb1->graph(0)->addData(key, rand()%100);
        ui->plot_nb2->graph(0)->addData(key, rand()%100);
        ui->plot_nb3->graph(0)->addData(key, rand()%100);
        ui->plot_nbW->graph(0)->addData(key, a);
        ui->plot_nbW->graph(1)->addData(key, b);
        ui->plot_nbW->graph(2)->addData(key, c);
    }
}

void MainWindow::CustomBar_car()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_S->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_S,"系统温度(℃)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_S->plotLayout()->insertRow(0);
    ui->plot_S->plotLayout()->addElement(0, 0, title_txt);

    Send1 = new CustomBar(ui->plot_S->xAxis, ui->plot_S->yAxis);
    //Send1->setName("风口"); // 设置图例
    Send1->setPen(QPen(QColor(30, 144, 255)));
    Send1->setBrush(QColor(30, 144, 255));
    Send1->setAntialiased(false);
    Send1->setStackingGap(1);//设置与下方柱子的像素点间隔

    QVector<QString> labels;
    ticks1 << 1 << 2 << 3 << 4 << 5;
    labels << "车辆电池" << "DCDC" << "整流桥" << "接收线圈" << "接收磁芯";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks1, labels);
    ui->plot_S->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_S->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_S->xAxis->setTickLength(0, 4);
    ui->plot_S->xAxis->setRange(0, 6);//设置x轴区间
    ui->plot_S->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_S->xAxis->setTickPen(Qt::NoPen);
    ui->plot_S->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_S->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_S->xAxis->setLabelColor(Qt::white);

    ui->plot_S->yAxis->setRange(0, 150);
    ui->plot_S->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_S->yAxis->setTickPen(Qt::NoPen);
    ui->plot_S->yAxis->setBasePen(Qt::NoPen);
    ui->plot_S->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_S->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_S->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_S->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_S->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_S->legend->setFont(legendFont);
    ui->plot_S->clearGraphs();

    QVector<double> R1_data1;
    R1_data1 << 50 << 65 << 45 << 55 << 70;
    Send1->setData(ticks1, R1_data1.toVector(),true);
    ui->plot_S->replot();
}

void MainWindow::CustomBar_dg()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_D->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_D,"导轨温度(℃)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_D->plotLayout()->insertRow(0);
    ui->plot_D->plotLayout()->addElement(0, 0, title_txt);

    Send2 = new CustomBar(ui->plot_D->xAxis, ui->plot_D->yAxis);
    //Send1->setName("风口"); // 设置图例
    Send2->setPen(QPen(QColor(0, 168, 140)));
    Send2->setBrush(QColor(0, 168, 140));
    Send2->setAntialiased(false);
    Send2->setStackingGap(1);//设置与下方柱子的像素点间隔

    QVector<QString> labels;
    ticks2 << 1 << 2 << 3 << 4;
    labels << "风口" << "电容1" << "电容2" << "电容3";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks2, labels);
    ui->plot_D->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_D->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_D->xAxis->setTickLength(0, 4);
    ui->plot_D->xAxis->setRange(0, 5);//设置x轴区间
    ui->plot_D->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_D->xAxis->setTickPen(Qt::NoPen);
    ui->plot_D->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_D->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_D->xAxis->setLabelColor(Qt::white);

    ui->plot_D->yAxis->setRange(0, 150);
    ui->plot_D->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_D->yAxis->setTickPen(Qt::NoPen);
    ui->plot_D->yAxis->setBasePen(Qt::NoPen);
    ui->plot_D->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_D->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_D->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_D->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_D->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_D->legend->setFont(legendFont);
    ui->plot_D->clearGraphs();

    QVector<double> R1_data1;
    R1_data1 << 35 << 38 << 40 << 55;
    Send2->setData(ticks2, R1_data1.toVector(),true);
    ui->plot_D->replot();
}

void MainWindow::CustomBar_sys()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_Sys->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //日期做X轴
    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
    ui->plot_Sys->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_Sys->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_Sys->xAxis->setTickPen(Qt::NoPen);
    ui->plot_Sys->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_Sys->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_Sys->xAxis->setLabelColor(Qt::white);
    ui->plot_Sys->xAxis->setTickLength(0, 7);
    //ui->plot_Sys->xAxis->setRange(0, 7);//设置x轴区间

    ui->plot_Sys->yAxis->setRange(0, 200);
    ui->plot_Sys->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_Sys->yAxis->setTickPen(Qt::NoPen);
    ui->plot_Sys->yAxis->setBasePen(Qt::NoPen);
    ui->plot_Sys->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_Sys->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_Sys->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_Sys->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_Sys->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_Sys->addGraph(ui->plot_Sys->xAxis,ui->plot_Sys->yAxis);//向绘图区域QCustomPlot添加一条曲线
    ui->plot_Sys->addGraph(ui->plot_Sys->xAxis,ui->plot_Sys->yAxis);

    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::blue);
    QPen pen1;
    pen1.setWidth(3);//设置线宽
    pen1.setColor(Qt::cyan);

    ui->plot_Sys->graph(0)->setPen(pen);
    ui->plot_Sys->graph(1)->setPen(pen1);
    //图例显示
    ui->plot_Sys->legend->setVisible(true);
    ui->plot_Sys->graph(0)->setName("系统功率(kW)");
    ui->plot_Sys->graph(1)->setName("充电功率(kW)");
    //图像自适应坐标轴
    ui->plot_Sys->graph(0)->rescaleAxes();
    ui->plot_Sys->graph(1)->rescaleAxes();

    ui->plot_Sys->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_Sys->legend->setBorderPen(Qt::NoPen);
    ui->plot_Sys->legend->setVisible(true);//设置曲线名称可见
    ui->plot_Sys->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_Sys->setCursor(QCursor(Qt::PointingHandCursor));
}

void MainWindow::CustomBar_System()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_System->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_System,"系统效率(%)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_System->plotLayout()->insertRow(0);
    ui->plot_System->plotLayout()->addElement(0, 0, title_txt);
//    //日期做X轴
//    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
//    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
//    ui->plot_Sys->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_System->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_System->xAxis->setTickPen(Qt::NoPen);
    ui->plot_System->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_System->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_System->xAxis->setLabelColor(Qt::white);
    ui->plot_System->xAxis->setRange(1, 7);

    ui->plot_System->yAxis->setRange(0, 100);
    ui->plot_System->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_System->yAxis->setTickPen(Qt::NoPen);
    ui->plot_System->yAxis->setBasePen(Qt::NoPen);
    ui->plot_System->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_System->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_System->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_System->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_System->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_System->addGraph(ui->plot_System->xAxis,ui->plot_System->yAxis);//向绘图区域QCustomPlot添加一条曲线

    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::green);

    ui->plot_System->graph(0)->setPen(pen);
    //图例显示
//    ui->plot_System->legend->setVisible(false);
//    ui->plot_System->graph(0)->setName("系统效率");
    //图像自适应坐标轴
    ui->plot_System->graph(0)->rescaleAxes();
//    ui->plot_Sys->graph(1)->rescaleAxes();

    ui->plot_System->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_System->legend->setBorderPen(Qt::NoPen);
//    ui->plot_System->legend->setVisible(true);//设置曲线名称可见
    ui->plot_System->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_System->setCursor(QCursor(Qt::PointingHandCursor));

    ui->plot_System->graph(0)->addData(1, 0);
    ui->plot_System->graph(0)->addData(2, 75);
    ui->plot_System->graph(0)->addData(3, 80);
    ui->plot_System->graph(0)->addData(4, 60);
    ui->plot_System->graph(0)->addData(5, 70);
    ui->plot_System->graph(0)->addData(6, 85);
    ui->plot_System->graph(0)->addData(7, 90);
}

void MainWindow::CustomBar_nb1()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_nb1->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_nb1,"相位占空比", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_nb1->plotLayout()->insertRow(0);
    ui->plot_nb1->plotLayout()->addElement(0, 0, title_txt);

    //日期做X轴
    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
    ui->plot_nb1->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_nb1->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_nb1->xAxis->setTickPen(Qt::NoPen);
    ui->plot_nb1->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_nb1->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_nb1->xAxis->setLabelColor(Qt::white);
    ui->plot_nb1->xAxis->setTickLength(0, 7);
    //ui->plot_Sys->xAxis->setRange(0, 7);//设置x轴区间

    ui->plot_nb1->yAxis->setRange(0, 100);
    ui->plot_nb1->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_nb1->yAxis->setTickPen(Qt::NoPen);
    ui->plot_nb1->yAxis->setBasePen(Qt::NoPen);
    ui->plot_nb1->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_nb1->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_nb1->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_nb1->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_nb1->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_nb1->addGraph(ui->plot_nb1->xAxis,ui->plot_nb1->yAxis);//向绘图区域QCustomPlot添加一条曲线
    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::blue);
    QPen pen1;
    pen1.setWidth(3);//设置线宽
    pen1.setColor(Qt::cyan);

    ui->plot_nb1->graph(0)->setPen(pen);
    //图例显示
    ui->plot_nb1->legend->setVisible(false);
    //ui->plot_nb1->graph(0)->setName("系统功率(kW)");
    //图像自适应坐标轴
    ui->plot_nb1->graph(0)->rescaleAxes();

    ui->plot_nb1->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_nb1->legend->setBorderPen(Qt::NoPen);
    //ui->plot_nb1->legend->setVisible(true);//设置曲线名称可见
    ui->plot_nb1->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_nb1->setCursor(QCursor(Qt::PointingHandCursor));
}

void MainWindow::CustomBar_nb2()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_nb2->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_nb2,"相位占空比", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_nb2->plotLayout()->insertRow(0);
    ui->plot_nb2->plotLayout()->addElement(0, 0, title_txt);

    //日期做X轴
    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
    ui->plot_nb2->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_nb2->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_nb2->xAxis->setTickPen(Qt::NoPen);
    ui->plot_nb2->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_nb2->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_nb2->xAxis->setLabelColor(Qt::white);
    ui->plot_nb2->xAxis->setTickLength(0, 7);
    //ui->plot_Sys->xAxis->setRange(0, 7);//设置x轴区间

    ui->plot_nb2->yAxis->setRange(0, 100);
    ui->plot_nb2->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_nb2->yAxis->setTickPen(Qt::NoPen);
    ui->plot_nb2->yAxis->setBasePen(Qt::NoPen);
    ui->plot_nb2->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_nb2->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_nb2->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_nb2->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_nb2->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_nb2->addGraph(ui->plot_nb2->xAxis,ui->plot_nb2->yAxis);//向绘图区域QCustomPlot添加一条曲线
    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::blue);
    QPen pen1;
    pen1.setWidth(3);//设置线宽
    pen1.setColor(Qt::cyan);

    ui->plot_nb2->graph(0)->setPen(pen);
    //图例显示
    ui->plot_nb2->legend->setVisible(false);
    //ui->plot_nb1->graph(0)->setName("系统功率(kW)");
    //图像自适应坐标轴
    ui->plot_nb2->graph(0)->rescaleAxes();

    ui->plot_nb2->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_nb2->legend->setBorderPen(Qt::NoPen);
    //ui->plot_nb1->legend->setVisible(true);//设置曲线名称可见
    ui->plot_nb2->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_nb2->setCursor(QCursor(Qt::PointingHandCursor));
}

void MainWindow::CustomBar_nb3()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_nb3->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_nb3,"相位占空比", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_nb3->plotLayout()->insertRow(0);
    ui->plot_nb3->plotLayout()->addElement(0, 0, title_txt);

    //日期做X轴
    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
    ui->plot_nb3->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_nb3->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_nb3->xAxis->setTickPen(Qt::NoPen);
    ui->plot_nb3->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_nb3->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_nb3->xAxis->setLabelColor(Qt::white);
    ui->plot_nb3->xAxis->setTickLength(0, 7);
    //ui->plot_Sys->xAxis->setRange(0, 7);//设置x轴区间

    ui->plot_nb3->yAxis->setRange(0, 100);
    ui->plot_nb3->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_nb3->yAxis->setTickPen(Qt::NoPen);
    ui->plot_nb3->yAxis->setBasePen(Qt::NoPen);
    ui->plot_nb3->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_nb3->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_nb3->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_nb3->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_nb3->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_nb3->addGraph(ui->plot_nb3->xAxis,ui->plot_nb3->yAxis);//向绘图区域QCustomPlot添加一条曲线
    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::blue);
    QPen pen1;
    pen1.setWidth(3);//设置线宽
    pen1.setColor(Qt::cyan);

    ui->plot_nb3->graph(0)->setPen(pen);
    //图例显示
    ui->plot_nb3->legend->setVisible(false);
    //ui->plot_nb1->graph(0)->setName("系统功率(kW)");
    //图像自适应坐标轴
    ui->plot_nb3->graph(0)->rescaleAxes();

    ui->plot_nb3->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_nb3->legend->setBorderPen(Qt::NoPen);
    //ui->plot_nb1->legend->setVisible(true);//设置曲线名称可见
    ui->plot_nb3->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_nb3->setCursor(QCursor(Qt::PointingHandCursor));
}

void MainWindow::CustomBar_nbtem()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_nbtem->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_nbtem,"单模块温度(℃)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_nbtem->plotLayout()->insertRow(0);
    ui->plot_nbtem->plotLayout()->addElement(0, 0, title_txt);

    nbtem1 = new CustomBar(ui->plot_nbtem->xAxis, ui->plot_nbtem->yAxis);
    //Send1->setName("风口"); // 设置图例
    nbtem1->setPen(QPen(QColor(30, 144, 255)));
    nbtem1->setBrush(QColor(30, 144, 255));
    nbtem1->setAntialiased(false);
    nbtem1->setStackingGap(1);//设置与下方柱子的像素点间隔

    nbtem2 = new CustomBar(ui->plot_nbtem->xAxis, ui->plot_nbtem->yAxis);
    //Send1->setName("风口"); // 设置图例
    nbtem2->setPen(QPen(QColor(111, 9, 176)));
    nbtem2->setBrush(QColor(111, 9, 176));
    nbtem2->setAntialiased(false);
    nbtem2->setStackingGap(1);//设置与下方柱子的像素点间隔

    //柱状图像素设置
    QCPBarsGroup *group = new QCPBarsGroup(ui->plot_nbtem);
    group->setSpacingType(QCPBarsGroup::stAbsolute);//设置组内柱状图的间距，按像素
    group->setSpacing(1);//设置较小的间距值，这样看起来更紧凑
    nbtem1->setBarsGroup(group);
    nbtem2->setBarsGroup(group);
    nbtem1->setWidth(0.3);
    nbtem2->setWidth(0.3);

    QVector<QString> labels;
    ticks3 << 1 << 2 << 3;
    labels << "逆变模块1" << "逆变模块2" << "逆变模块3";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks3, labels);
    ui->plot_nbtem->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_nbtem->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_nbtem->xAxis->setTickLength(0, 4);
    ui->plot_nbtem->xAxis->setRange(0, 4);//设置x轴区间
    ui->plot_nbtem->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_nbtem->xAxis->setTickPen(Qt::NoPen);
    ui->plot_nbtem->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_nbtem->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_nbtem->xAxis->setLabelColor(Qt::white);

    ui->plot_nbtem->yAxis->setRange(0, 150);
    ui->plot_nbtem->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_nbtem->yAxis->setTickPen(Qt::NoPen);
    ui->plot_nbtem->yAxis->setBasePen(Qt::NoPen);
    ui->plot_nbtem->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_nbtem->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_nbtem->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_nbtem->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_nbtem->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_nbtem->legend->setFont(legendFont);
    ui->plot_nbtem->clearGraphs();

    QVector<double> R1_data1,R1_data2;
    R1_data1 << 50 << 65 << 45;
    R1_data2 << 60 << 60 << 55;
    nbtem1->setData(ticks3, R1_data1.toVector(),true);
    nbtem2->setData(ticks3, R1_data2.toVector(),true);
    ui->plot_nbtem->replot();
}

void MainWindow::CustomBar_nbW()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_nbW->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）
    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_nbW,"单模输出功率(kW)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_nbW->plotLayout()->insertRow(0);
    ui->plot_nbW->plotLayout()->addElement(0, 0, title_txt);

    //日期做X轴
    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
    ui->plot_nbW->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_nbW->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_nbW->xAxis->setTickPen(Qt::NoPen);
    ui->plot_nbW->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_nbW->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_nbW->xAxis->setLabelColor(Qt::white);
    ui->plot_nbW->xAxis->setTickLength(0, 7);
    //ui->plot_Sys->xAxis->setRange(0, 7);//设置x轴区间

    ui->plot_nbW->yAxis->setRange(0, 200);
    ui->plot_nbW->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_nbW->yAxis->setTickPen(Qt::NoPen);
    ui->plot_nbW->yAxis->setBasePen(Qt::NoPen);
    ui->plot_nbW->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_nbW->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_nbW->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_nbW->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_nbW->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_nbW->addGraph(ui->plot_nbW->xAxis,ui->plot_nbW->yAxis);//向绘图区域QCustomPlot添加一条曲线
    ui->plot_nbW->addGraph(ui->plot_nbW->xAxis,ui->plot_nbW->yAxis);
    ui->plot_nbW->addGraph(ui->plot_nbW->xAxis,ui->plot_nbW->yAxis);

    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(QColor(51,161,201));
    QPen pen1;
    pen1.setWidth(3);//设置线宽
    pen1.setColor(QColor(61,145,64));
    QPen pen2;
    pen2.setWidth(3);//设置线宽
    pen2.setColor(QColor(255,255,0));

    ui->plot_nbW->graph(0)->setPen(pen);
    ui->plot_nbW->graph(1)->setPen(pen1);
    ui->plot_nbW->graph(2)->setPen(pen2);
    //图例显示
    ui->plot_nbW->legend->setVisible(false);
    //ui->plot_nbW->graph(0)->setName("系统功率(kW)");
    //ui->plot_nbW->graph(1)->setName("充电功率(kW)");
    //图像自适应坐标轴
    ui->plot_nbW->graph(0)->rescaleAxes();
    ui->plot_nbW->graph(1)->rescaleAxes();
    ui->plot_nbW->graph(2)->rescaleAxes();

    ui->plot_nbW->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_nbW->legend->setBorderPen(Qt::NoPen);
    //ui->plot_nbW->legend->setVisible(false);//设置曲线名称可见
    ui->plot_nbW->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_nbW->setCursor(QCursor(Qt::PointingHandCursor));
}

void MainWindow::CustomBar_DC()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_DC->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_DC,"温度数据(℃)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_DC->plotLayout()->insertRow(0);
    ui->plot_DC->plotLayout()->addElement(0, 0, title_txt);

    DC1 = new CustomBar(ui->plot_DC->xAxis, ui->plot_DC->yAxis);
    //Send1->setName("风口"); // 设置图例
    DC1->setPen(QPen(QColor(30, 144, 255)));
    DC1->setBrush(QColor(30, 144, 255));
    DC1->setAntialiased(false);
    DC1->setStackingGap(1);//设置与下方柱子的像素点间隔

    QVector<QString> labels;
    ticks4 << 1 << 2 << 3 << 4;
    labels << "DCDC上桥" << "DCDC下桥" << "DCDC电感" << "整流桥";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks4, labels);
    ui->plot_DC->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_DC->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_DC->xAxis->setTickLength(0, 4);
    ui->plot_DC->xAxis->setRange(0, 5);//设置x轴区间
    ui->plot_DC->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_DC->xAxis->setTickPen(Qt::NoPen);
    ui->plot_DC->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_DC->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_DC->xAxis->setLabelColor(Qt::white);

    ui->plot_DC->yAxis->setRange(0, 150);
    ui->plot_DC->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_DC->yAxis->setTickPen(Qt::NoPen);
    ui->plot_DC->yAxis->setBasePen(Qt::NoPen);
    ui->plot_DC->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_DC->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_DC->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_DC->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_DC->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_DC->legend->setFont(legendFont);
    ui->plot_DC->clearGraphs();

    QVector<double> R1_data1;
    R1_data1 << 50 << 65 << 45 << 55;
    DC1->setData(ticks4, R1_data1.toVector(),true);
    ui->plot_DC->replot();
}

void MainWindow::CustomBar_Charge()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_charge->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_charge,"温度数据(℃)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_charge->plotLayout()->insertRow(0);
    ui->plot_charge->plotLayout()->addElement(0, 0, title_txt);

    Charge1 = new CustomBar(ui->plot_charge->xAxis, ui->plot_charge->yAxis);
    //Send1->setName("风口"); // 设置图例
    Charge1->setPen(QPen(QColor(30, 144, 255)));
    Charge1->setBrush(QColor(30, 144, 255));
    Charge1->setAntialiased(false);
    Charge1->setStackingGap(1);//设置与下方柱子的像素点间隔

    QVector<QString> labels;
    ticks5 << 1 << 2 << 3 << 4;
    labels << "电池模块1" << "电池模块2" << "电池模块3" << "电池模块4";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks5, labels);
    ui->plot_charge->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_charge->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_charge->xAxis->setTickLength(0, 4);
    ui->plot_charge->xAxis->setRange(0, 5);//设置x轴区间
    ui->plot_charge->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_charge->xAxis->setTickPen(Qt::NoPen);
    ui->plot_charge->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_charge->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_charge->xAxis->setLabelColor(Qt::white);

    ui->plot_charge->yAxis->setRange(0, 150);
    ui->plot_charge->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_charge->yAxis->setTickPen(Qt::NoPen);
    ui->plot_charge->yAxis->setBasePen(Qt::NoPen);
    ui->plot_charge->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_charge->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_charge->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_charge->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_charge->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_charge->legend->setFont(legendFont);
    ui->plot_charge->clearGraphs();

    QVector<double> R1_data1;
    R1_data1 << 50 << 65 << 45 << 55;
    Charge1->setData(ticks5, R1_data1.toVector(),true);
    ui->plot_charge->replot();
}

void MainWindow::CustomBar_JS()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_js->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_js,"温度数据(℃)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_js->plotLayout()->insertRow(0);
    ui->plot_js->plotLayout()->addElement(0, 0, title_txt);

    JS1 = new CustomBar(ui->plot_js->xAxis, ui->plot_js->yAxis);
    //Send1->setName("风口"); // 设置图例
    JS1->setPen(QPen(QColor(30, 144, 255)));
    JS1->setBrush(QColor(30, 144, 255));
    JS1->setAntialiased(false);
    JS1->setStackingGap(1);//设置与下方柱子的像素点间隔

    QVector<QString> labels;
    ticks6 << 1 << 2 << 3 << 4 << 5;
    labels << "DD线圈" << "DD磁芯" << "Q线圈" << "Q磁芯" << "电容";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks6, labels);
    ui->plot_js->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_js->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_js->xAxis->setTickLength(0, 4);
    ui->plot_js->xAxis->setRange(0, 6);//设置x轴区间
    ui->plot_js->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_js->xAxis->setTickPen(Qt::NoPen);
    ui->plot_js->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_js->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_js->xAxis->setLabelColor(Qt::white);

    ui->plot_js->yAxis->setRange(0, 150);
    ui->plot_js->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_js->yAxis->setTickPen(Qt::NoPen);
    ui->plot_js->yAxis->setBasePen(Qt::NoPen);
    ui->plot_js->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_js->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_js->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_js->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_js->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_js->legend->setFont(legendFont);
    ui->plot_js->clearGraphs();

    QVector<double> R1_data1;
    R1_data1 << 50 << 65 << 45 << 55 << 75;
    JS1->setData(ticks6, R1_data1.toVector(),true);
    ui->plot_js->replot();
}

void MainWindow::CustomBar_Js_Sys()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_js_Sys->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

    //添加图的title
    QCPTextElement *title_txt = new QCPTextElement(ui->plot_js_Sys,"系统效率(%)", QFont("sans", 12, QFont::Bold));
    title_txt->setTextColor(Qt::white);  //修改颜色
    ui->plot_js_Sys->plotLayout()->insertRow(0);
    ui->plot_js_Sys->plotLayout()->addElement(0, 0, title_txt);
//    //日期做X轴
//    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
//    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
//    ui->plot_Sys->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_js_Sys->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_js_Sys->xAxis->setTickPen(Qt::NoPen);
    ui->plot_js_Sys->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_js_Sys->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_js_Sys->xAxis->setLabelColor(Qt::white);
    ui->plot_js_Sys->xAxis->setRange(1, 7);

    ui->plot_js_Sys->yAxis->setRange(0, 100);
    ui->plot_js_Sys->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_js_Sys->yAxis->setTickPen(Qt::NoPen);
    ui->plot_js_Sys->yAxis->setBasePen(Qt::NoPen);
    ui->plot_js_Sys->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_js_Sys->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_js_Sys->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_js_Sys->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_js_Sys->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_js_Sys->addGraph(ui->plot_js_Sys->xAxis,ui->plot_js_Sys->yAxis);//向绘图区域QCustomPlot添加一条曲线

    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::blue);

    ui->plot_js_Sys->graph(0)->setPen(pen);
    //图例显示
//    ui->plot_System->legend->setVisible(false);
//    ui->plot_System->graph(0)->setName("系统效率");
    //图像自适应坐标轴
    ui->plot_js_Sys->graph(0)->rescaleAxes();
//    ui->plot_Sys->graph(1)->rescaleAxes();

    ui->plot_js_Sys->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_js_Sys->legend->setBorderPen(Qt::NoPen);
//    ui->plot_System->legend->setVisible(true);//设置曲线名称可见
    ui->plot_js_Sys->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_js_Sys->setCursor(QCursor(Qt::PointingHandCursor));

    ui->plot_js_Sys->graph(0)->addData(1, 0);
    ui->plot_js_Sys->graph(0)->addData(2, 75);
    ui->plot_js_Sys->graph(0)->addData(3, 80);
    ui->plot_js_Sys->graph(0)->addData(4, 60);
    ui->plot_js_Sys->graph(0)->addData(5, 70);
    ui->plot_js_Sys->graph(0)->addData(6, 85);
    ui->plot_js_Sys->graph(0)->addData(7, 90);
}

void MainWindow::CustomBar_DG()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_DG->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

//    //添加图的title
//    QCPTextElement *title_txt = new QCPTextElement(ui->plot_DG,"温度数据(℃)", QFont("sans", 12, QFont::Bold));
//    title_txt->setTextColor(Qt::white);  //修改颜色
//    ui->plot_DG->plotLayout()->insertRow(0);
//    ui->plot_DG->plotLayout()->addElement(0, 0, title_txt);

    DG1 = new QCPBars(ui->plot_DG->xAxis, ui->plot_DG->yAxis);
    //Send1->setName("风口"); // 设置图例
    DG1->setPen(QPen(QColor(30, 144, 255)));
    DG1->setBrush(QColor(30, 144, 255));
    DG1->setAntialiased(false);
    DG1->setStackingGap(1);//设置与下方柱子的像素点间隔
    DG2 = new QCPBars(ui->plot_DG->xAxis, ui->plot_DG->yAxis);
    //Send1->setName("风口"); // 设置图例
    DG2->setPen(QPen(QColor(3, 168 ,158)));
    DG2->setBrush(QColor(3, 168 ,158));
    DG2->setAntialiased(false);
    DG2->setStackingGap(1);//设置与下方柱子的像素点间隔

    //柱状图像素设置
    QCPBarsGroup *group = new QCPBarsGroup(ui->plot_nbtem);
    group->setSpacingType(QCPBarsGroup::stAbsolute);//设置组内柱状图的间距，按像素
    group->setSpacing(1);//设置较小的间距值，这样看起来更紧凑
    DG1->setBarsGroup(group);
    DG2->setBarsGroup(group);
    DG1->setWidth(0.35);
    DG2->setWidth(0.35);

    QVector<QString> labels;
    ticks7 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << 19 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27 << 28 << 29 << 30;
    labels << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10" << "11" << "12" << "13" << "14" << "15" << "16" << "17" << "18" << "19" << "20" << "21" << "22" << "23" << "24" << "25" << "26" << "27" << "28" << "29" << "30";
    QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
    textTicker->addTicks(ticks7, labels);
    ui->plot_DG->xAxis->setTicker(textTicker);
    //ui->plot_Rec_2->xAxis->setTickLabelRotation(-60);//设置标签角度旋转
    ui->plot_DG->xAxis->setSubTicks(false);//设置是否显示子标签
    ui->plot_DG->xAxis->setTickLength(0, 4);
    ui->plot_DG->xAxis->setRange(0, 31);//设置x轴区间
    ui->plot_DG->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_DG->xAxis->setTickPen(Qt::NoPen);
    ui->plot_DG->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_DG->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_DG->xAxis->setLabelColor(Qt::white);

    ui->plot_DG->yAxis->setRange(0, 150);
    ui->plot_DG->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_DG->yAxis->setTickPen(Qt::NoPen);
    ui->plot_DG->yAxis->setBasePen(Qt::NoPen);
    ui->plot_DG->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_DG->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_DG->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_DG->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_DG->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->plot_DG->legend->setFont(legendFont);
    ui->plot_DG->clearGraphs();

    QVector<double> R1_data1,R1_data2;
    R1_data1 << 50 << 65 << 45 << 55 << 75 << 60 << 70 << 30 << 45 << 55 << 50 << 60 << 40 << 70 << 55 << 80 << 70 << 60 << 55 << 75 << 55 << 65 << 50 << 75 << 45 << 70 << 65 << 80 << 45 << 75;
    R1_data2 << 40 << 50 << 60 << 45 << 60 << 45 << 60 << 75 << 55 << 65 << 30 << 50 << 70 << 55 << 65 << 50 << 45 << 55 << 60 << 70 << 40 << 50 << 60 << 45 << 60 << 55 << 50 << 70 << 55 << 60;
    DG1->setData(ticks7, R1_data1.toVector(),true);
    DG2->setData(ticks7, R1_data2.toVector(),true);
    ui->plot_DG->replot();
}

void MainWindow::CustomBar_Bug()
{
    QLinearGradient gradient(0, 0, 0, 400);
    gradient.setColorAt(0, QColor(110, 110, 110,0));
    gradient.setColorAt(0.38, QColor(110, 110, 110,0));
    gradient.setColorAt(1, QColor(110, 110, 110,0));
    ui->plot_Bug->setBackground(QBrush(gradient));//设置图表背景（用画刷设置）

//    //添加图的title
//    QCPTextElement *title_txt = new QCPTextElement(ui->plot_Bug,"系统效率(%)", QFont("sans", 12, QFont::Bold));
//    title_txt->setTextColor(Qt::white);  //修改颜色
//    ui->plot_Bug->plotLayout()->insertRow(0);
//    ui->plot_Bug->plotLayout()->addElement(0, 0, title_txt);
//    //日期做X轴
//    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
//    dateTicker->setDateTimeFormat("hh:mm:ss"); //日期格式
//    ui->plot_Sys->xAxis->setTicker(dateTicker); //设置X轴为时间

    ui->plot_Bug->xAxis->setBasePen(QPen(QColor(130, 130, 130)));
    ui->plot_Bug->xAxis->setTickPen(Qt::NoPen);
    ui->plot_Bug->xAxis->grid()->setVisible(false);//设置网格是否显示
    //ui->plot_S->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
    ui->plot_Bug->xAxis->setTickLabelColor(Qt::white);//设置标记标签颜色
    ui->plot_Bug->xAxis->setLabelColor(Qt::white);
    ui->plot_Bug->xAxis->setRange(1, 7);

    ui->plot_Bug->yAxis->setRange(0, 300);
    ui->plot_Bug->yAxis->setPadding(5); // a bit more space to the left border 设置左边留空间
    ui->plot_Bug->yAxis->setTickPen(Qt::NoPen);
    ui->plot_Bug->yAxis->setBasePen(Qt::NoPen);
    ui->plot_Bug->yAxis->setSubTickPen(Qt::NoPen);//设置SubTick颜色，SubTick指的是轴上的

    //刻度线
    //ui->qcustomplot->yAxis->grid()->setSubGridVisible(true);
    ui->plot_Bug->yAxis->setTickLabelColor(Qt::white);//设置标记标签颜色（y轴标记标签）
    ui->plot_Bug->yAxis->setLabelColor(Qt::white);//设置标签颜色（y轴右边标签）
    ui->plot_Bug->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 1, Qt::SolidLine));
    ui->plot_Bug->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));

    ui->plot_Bug->addGraph(ui->plot_Bug->xAxis,ui->plot_Bug->yAxis);//向绘图区域QCustomPlot添加一条曲线

    QPen pen;
    pen.setWidth(3);//设置线宽
    pen.setColor(Qt::blue);

    ui->plot_Bug->graph(0)->setPen(pen);
    //图例显示
//    ui->plot_System->legend->setVisible(false);
//    ui->plot_System->graph(0)->setName("系统效率");
    //图像自适应坐标轴
    ui->plot_Bug->graph(0)->rescaleAxes();
//    ui->plot_Sys->graph(1)->rescaleAxes();

    ui->plot_Bug->legend->setBrush(QBrush(Qt::transparent));     //设置图例透明无边框
    //plot_2->legend->setBorderPen(Qt::NoPen);//图例边框隐藏
    //plot_2->legend->setFont(QFont("sans", 16, QFont::Bold));
    ui->plot_Bug->legend->setBorderPen(Qt::NoPen);
//    ui->plot_System->legend->setVisible(true);//设置曲线名称可见
    ui->plot_Bug->legend->setTextColor(Qt::white);//black

    //设置鼠标放于绘图区，变为手型
    ui->plot_Bug->setCursor(QCursor(Qt::PointingHandCursor));

    ui->plot_Bug->graph(0)->addData(1, 75);
    ui->plot_Bug->graph(0)->addData(2, 100);
    ui->plot_Bug->graph(0)->addData(3, 130);
    ui->plot_Bug->graph(0)->addData(4, 100);
    ui->plot_Bug->graph(0)->addData(5, 180);
    ui->plot_Bug->graph(0)->addData(6, 90);
    ui->plot_Bug->graph(0)->addData(7, 120);
}

void MainWindow::TCPCar(bool bo)
{
    if(bo == true){
        ui->label_car->setStyleSheet("border-image: url(:/new/prefix1/image/train-wifi-fill2.png)");
    }else{
        ui->label_car->setStyleSheet("border-image: url(:/new/prefix1/image/train-wifi-fill3.png)");
    }
}

void MainWindow::TCPDG()
{
    ui->label_dg->setStyleSheet("border-image: url(:/new/prefix1/image/dgwifi (7).png)");
}

void MainWindow::DG1View(QString da)
{
    //PLC输出状态Q
    if(da.mid(2,2) == "01")
    {
        QString data = QString("%1").arg(da.mid(6,2).toInt(0,16), 8, 2, QLatin1Char('0'));
        if(data.mid(7,1) == "1"){
            ui->lineEdit_FS1->setStyleSheet("font: 25 13pt '微软雅黑 Light';" //字体
                                       "color: rgb(31,31,31);"		//字体颜色
                                       "padding-left:10px;"       //内边距-字体缩进
                                       "background-color: rgb(255, 255, 255);" //背景颜色
                                       "border:3px solid rgb(20,196,188);border-radius:5px;");//边框粗细-颜色-圆角设置
            ui->lineEdit_FS1->setText("风扇启动");
            //qDebug()<<"风扇启动";
        }else{
            ui->lineEdit_FS1->setStyleSheet("font: 25 13pt '微软雅黑 Light';" //字体
                                       "color: rgb(255,0,0);"		//字体颜色
                                       "padding-left:10px;"       //内边距-字体缩进
                                       "background-color: rgb(255, 255, 255);" //背景颜色
                                       "border:3px solid rgb(20,196,188);border-radius:5px;");//边框粗细-颜色-圆角设置
            ui->lineEdit_FS1->setText("风扇未启动");
            //qDebug()<<"风扇未启动";
        }
        if(data.mid(6,1) == "1"){
            ui->lineEdit_KG1->setStyleSheet("font: 25 13pt '微软雅黑 Light';" //字体
                                       "color: rgb(255,0,0);"		//字体颜色
                                       "padding-left:15px;"       //内边距-字体缩进
                                       "background-color: rgb(255, 255, 255);" //背景颜色
                                       "border:3px solid rgb(20,196,188);border-radius:5px;");
            ui->lineEdit_KG1->setText("线圈断电");
            //ui->car1->setStyleSheet("border-image: url()");
        }else{
            ui->lineEdit_KG1->setStyleSheet("font: 25 13pt '微软雅黑 Light';" //字体
                                       "color: rgb(31,31,31);"		//字体颜色
                                       "padding-left:15px;"       //内边距-字体缩进
                                       "background-color: rgb(255, 255, 255);" //背景颜色
                                       "border:3px solid rgb(20,196,188);border-radius:5px;");
            ui->lineEdit_KG1->setText("线圈通电");
            //ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
            //ui->navProgress->setCurrentStep(1);
            //ui->car1->setStyleSheet("border-image: url(:/new/prefix1/icons/bus (5).png)");
            //signCar1();
        }
    }
}

void MainWindow::DG2View(QString da)
{

}

void MainWindow::DG3View(QString da)
{

}

void MainWindow::DG4View(QString da)
{

}

void MainWindow::DG5View(QString da)
{

}

void MainWindow::DG6View(QString da)
{

}

void MainWindow::DG7View(QString da)
{

}

void MainWindow::DG8View(QString da)
{

}

void MainWindow::DG9View(QString da)
{

}

void MainWindow::DCDC1DATA(QString da)
{
    if(da.mid(0,1) == "1")
    {
        DC1_inV = da.mid(1,4).toInt(0,16);//16进制转10进制
        DC1_inA = da.mid(5,2).toInt(0,16);
        DC1_putV = da.mid(7,4).toInt(0,16);
        DC1_putA = da.mid(11,2).toInt(0,16);
        ZLQ1_inV = da.mid(13,4).toInt(0,16);
        ui->EditDC_inV->setText(QString::number(DC1_inV));
        ui->EditDC_inA->setText(QString::number(DC1_inA));
        ui->labelDC_putV->setText(QString::number(DC1_putV)+"V");
        ui->labelDC_putA->setText(QString::number(DC1_putA)+"A");
        ui->EditDC_ZL_V->setText(QString::number(ZLQ1_inV));
        DC1_inW = DC1_inV*DC1_inA/1000;
        DC1_putW = DC1_putV*DC1_putA/1000;
        ui->ArcDC_inW->setValue(DC1_inW);
        ui->ArcDC_putW->setValue(DC1_putW);
    }else if(da.mid(0,1) == "2")
    {
        ZLQ1_inA =  da.mid(1,2).toInt(0,16);
        ui->EditDC_ZL_A->setText(QString::number(ZLQ1_inA));
        SQ1Tem =  da.mid(3,2).toInt(0,16);
        XQ1Tem =  da.mid(5,2).toInt(0,16);
        DG1Tem =  da.mid(7,2).toInt(0,16);
        QString da5 = QString("%1").arg(da.mid(9,2).toInt(0,16), 8, 2, QLatin1Char('0'));//DCDC状态
        QString byte1 = da5.mid(0,1);//输入过压
        QString byte2 = da5.mid(1,1);//输出过压
        QString byte3 = da5.mid(2,1);//输入过流
        QString byte4 = da5.mid(3,1);//上管过温
        QString byte5 = da5.mid(4,1);//下管过温
        QString byte6 = da5.mid(5,1);//电感过温
        QString da6 = da.mid(11,2);//当前占空比
        int da7 = da.mid(13,2).toInt(0,16);//DCDC状态

        int ZKB = da6.toInt(0,16);
        ui->EditDC_ZKB->setText(QString::number(ZKB));
        ui->label_ZKB->setText(QString::number(ZKB));
        if(da7 == 0){
            //ui->light_key1->setGreen();
            ui->Edit_DCmodel->setText("恒压");
        }else if(da7 == 1){
            //ui->light_key1->setGreen();
            ui->Edit_DCmodel->setText("恒流");
        }else if(da7 == 2){
            //ui->light_key1->setGreen();
            ui->Edit_DCmodel->setText("恒功率");
        }else if(da7 == 3){
            //ui->light_key1->setGreen();
            ui->Edit_DCmodel->setText("恒占空比");
        }else if(da7 == 4){
            //ui->Edit_model->setText("恒占空比");
        }else if(da7 == 5){
            //ui->light_key1->setRed();
            ui->Edit_DCmodel->setText("关机");
        }

        //输入过压
        if(byte1 == "0"){
            dcbug1_1 = "0";
        }else if(byte1 == "1"){
            dcbug1_1 = "1";
        }
        //输出过压
        if(byte2 == "0"){
            dcbug1_2 = "0";
        }else if(byte2 == "1"){
            dcbug1_2 = "1";
        }
        //输出过流
        if(byte3 == "0"){
            dcbug1_3 = "0";
        }else if(byte3 == "1"){
            dcbug1_3 = "1";
        }
        //上管过温
        if(byte4 == "0"){
            dcbug1_4 = "0";
        }else if(byte4 == "1"){
            dcbug1_4 = "1";
        }
        //下管过温
        if(byte5 == "0"){
            dcbug1_5 = "0";
        }else if(byte5 == "1"){
            dcbug1_5 = "1";
        }
        //电感过温
        if(byte6 == "0"){
            dcbug1_6 = "0";
        }else if(byte6 == "1"){
            dcbug1_6 = "1";
        }

        QString BUG = dcbug1_1+dcbug1_2+dcbug1_3+dcbug1_4+dcbug1_5+dcbug1_6;
        if(BUG == "000000"){
            //ui->light_bug1->setGreen();
        }else{
            //ui->light_bug1->setRed();
        }
        if(dcbug1_1 == "0"){
            ui->lightDC_srgy->setGreen();
        }else{
            ui->lightDC_srgy->setRed();
        }
        if(dcbug1_2 == "0"){
            ui->lightDC_scgy->setGreen();
        }else{
            ui->lightDC_scgy->setRed();
        }
        if(dcbug1_3 == "0"){
            ui->lightDC_scgl->setGreen();
        }else{
            ui->lightDC_scgl->setRed();
        }
        if(dcbug1_4 == "0"){
            ui->lightDC_sggw->setGreen();
        }else{
            ui->lightDC_sggw->setRed();
        }
        if(dcbug1_5 == "0"){
            ui->lightDC_xggw->setGreen();
        }else{
            ui->lightDC_xggw->setRed();
        }
        if(dcbug1_6 == "0"){
            ui->lightDC_dggw->setGreen();
        }else{
            ui->lightDC_dggw->setRed();
        }
    }
}

void MainWindow::LocationView(QString da)
{
    QString byte1 = da.mid(0,2);
    QString byte2 = da.mid(2,2);
    QString byte3 = da.mid(4,2);
    QString byte4 = da.mid(6,2);
    QString byte5 = da.mid(8,2);
    QString byte6 = da.mid(10,2);
    QString byte7 = da.mid(12,2);
    QString byte8 = da.mid(14,2);

    //位置信息
    int X = byte5.toInt(0,16)+byte4.toInt(0,16)*128+byte3.toInt(0,16)*16384+byte2.toInt(0,16)*2097152;
    int speed = byte6.toInt(0,16);
    int Y = byte8.toInt(0,16);

    //状态信息
    QString byte = QString("%1").arg(byte1.toInt(0,16), 8, 2, QLatin1Char('0'));//状态2
    QString byte1_0 = byte.mid(0,1);//错误标志位
    QString byte1_1 = byte.mid(1,1);//无位置标志位
    QString byte1_2 = byte.mid(2,1);//报警标志位
    QString byte1_3 = byte.mid(3,1);//事件标志位

    //导轨1开关动作
    if(X >= dg1_min && X <= dg1_max)
    {
        sendDataK1();
        //sendDataC2();
        ui->car1->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car2->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(1);
        qDebug()<<"导轨1打开";
    }
    //导轨2开关动作
    if(X > dg1_max && X <= dg2_max)
    {
        sendDataC1();
//        sendDataC3();
//        sendDataK2();
        ui->car2->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car1->setStyleSheet("border-image: url()");
        ui->car3->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(2);
        qDebug()<<"导轨2打开";
    }
    //导轨3开关动作
    if(X > dg2_max && X <= dg3_max)
    {
        sendDataK1();
//        sendDataC4();
//        sendDataK3();
        ui->car3->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car2->setStyleSheet("border-image: url()");
        ui->car4->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(3);
        qDebug()<<"导轨3打开";
    }
    //导轨4开关动作
    if(X > dg3_max && X <= dg4_max)
    {
        sendDataC1();
//        sendDataC5();
//        sendDataK4();
        ui->car4->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car3->setStyleSheet("border-image: url()");
        ui->car5->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(4);
        qDebug()<<"导轨4打开";
    }
    //导轨5开关动作
    if(X > dg4_max && X <= dg5_max)
    {
        sendDataK1();
//        sendDataC6();
//        sendDataK5();
        ui->car5->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car4->setStyleSheet("border-image: url()");
        ui->car6->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(5);
        qDebug()<<"导轨5打开";
    }
    //导轨6开关动作
    if(X > dg5_max && X <= dg6_max)
    {
        sendDataC1();
//        sendDataC7();
//        sendDataK6();
        ui->car6->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car5->setStyleSheet("border-image: url()");
        ui->car7->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(6);
        qDebug()<<"导轨6打开";
    }
    //导轨7开关动作
    if(X > dg6_max && X <= dg7_max)
    {
        sendDataK1();
//        sendDataC8();
//        sendDataK7();
        ui->car7->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car6->setStyleSheet("border-image: url()");
        ui->car8->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(7);
        qDebug()<<"导轨7打开";
    }
    //导轨8开关动作
    if(X > dg7_max && X <= dg8_max)
    {
        sendDataC1();
//        sendDataC9();
//        sendDataK8();
        ui->car8->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car7->setStyleSheet("border-image: url()");
        ui->car9->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(8);
        qDebug()<<"导轨8打开";
    }
    //导轨9开关动作
    if(X > dg8_max && X <= dg9_max)
    {
        sendDataK1();
//        sendDataC10();
//        sendDataK9();
        ui->car9->setStyleSheet("border-image: url(:/new/prefix1/image/dw.png)");
        ui->car8->setStyleSheet("border-image: url()");
        ui->car10->setStyleSheet("border-image: url()");
        ui->navProgress->setCurrentBackground(QColor("#00BFFF"));
        ui->navProgress->setCurrentStep(9);
        qDebug()<<"导轨9打开";
    }
    //导轨10开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨11开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨12开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨13开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨14开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨15开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨16开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨17开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨18开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨19开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨20开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨21开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨22开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨23开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨24开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨25开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨26开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨27开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨28开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨29开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
    //导轨30开关动作
    if(X > dg8_max && X <= dg9_max)
    {

    }
}

void MainWindow::CarTemView(QString da)
{

}

void MainWindow::InitTableDG()
{
    ui->tableDG->setRowCount(10);   //7行
    ui->tableDG->setColumnCount(31);   //6列
    ui->tableDG->setFrameShape(QFrame::NoFrame); //设置边框
    //ui->tableDG->setFixedSize(1900,300);   //固定大小
    ui->tableDG->verticalHeader()->setVisible(false); //设置垂直头不可见
    ui->tableDG->horizontalHeader()->setVisible(false);   //设置水平头不可见
    ui->tableDG->setSelectionMode(QAbstractItemView::ExtendedSelection); //可多选（Ctrl、Shift、 Ctrl+A都可以）
    ui->tableDG->setSelectionBehavior(QAbstractItemView::SelectRows); //设置选择行为时每次选择一行
    ui->tableDG->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置不可编辑
    //ui->tableDG->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条
    //ui->tableDG->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);  //去掉垂直滚动条
    //ui->tableDG->setFont(QFont("Helvetica"));

//    ui->tableDG->setColumnWidth(0,200);
//    ui->tableDG->setColumnWidth(1,100);
//    ui->tableDG->setColumnWidth(2,100);
//    ui->tableDG->setColumnWidth(3,100);
//    ui->tableDG->setColumnWidth(4,100);
//    ui->tableDG->setColumnWidth(5,100);

    ui->tableDG->setAlternatingRowColors(true);
    //ui->tableDG->setFrameShape(QFrame::NoFrame); //设置边框
    ui->tableDG->setFocusPolicy(Qt::NoFocus); //去除选中虚线框

    QPalette palette;    //调色板
    //palette.setColor(QPalette::Base, QColor(0,255,0));   //基底
    //palette.setColor(QPalette::AlternateBase, QColor(233,245,252));  //交替基底
    //ui->tableDG->setPalette(palette);

    //表头列文本设置
    ui->tableDG->setItem(0, 0, new QTableWidgetItem("故障"));
    ui->tableDG->setItem(0, 1, new QTableWidgetItem("导轨1"));
    ui->tableDG->setItem(0, 2, new QTableWidgetItem("导轨2"));
    ui->tableDG->setItem(0, 3, new QTableWidgetItem("导轨3"));
    ui->tableDG->setItem(0, 4, new QTableWidgetItem("导轨4"));
    ui->tableDG->setItem(0, 5, new QTableWidgetItem("导轨5"));
    ui->tableDG->setItem(0, 6, new QTableWidgetItem("导轨6"));
    ui->tableDG->setItem(0, 7, new QTableWidgetItem("导轨7"));
    ui->tableDG->setItem(0, 8, new QTableWidgetItem("导轨8"));
    ui->tableDG->setItem(0, 9, new QTableWidgetItem("导轨9"));
    ui->tableDG->setItem(0, 10, new QTableWidgetItem("导轨10"));
    ui->tableDG->setItem(0, 11, new QTableWidgetItem("导轨11"));
    ui->tableDG->setItem(0, 12, new QTableWidgetItem("导轨12"));
    ui->tableDG->setItem(0, 13, new QTableWidgetItem("导轨13"));
    ui->tableDG->setItem(0, 14, new QTableWidgetItem("导轨14"));
    ui->tableDG->setItem(0, 15, new QTableWidgetItem("导轨15"));
    ui->tableDG->setItem(0, 16, new QTableWidgetItem("导轨16"));
    ui->tableDG->setItem(0, 17, new QTableWidgetItem("导轨17"));
    ui->tableDG->setItem(0, 18, new QTableWidgetItem("导轨18"));
    ui->tableDG->setItem(0, 19, new QTableWidgetItem("导轨19"));
    ui->tableDG->setItem(0, 20, new QTableWidgetItem("导轨20"));
    ui->tableDG->setItem(0, 21, new QTableWidgetItem("导轨21"));
    ui->tableDG->setItem(0, 22, new QTableWidgetItem("导轨22"));
    ui->tableDG->setItem(0, 23, new QTableWidgetItem("导轨23"));
    ui->tableDG->setItem(0, 24, new QTableWidgetItem("导轨24"));
    ui->tableDG->setItem(0, 25, new QTableWidgetItem("导轨25"));
    ui->tableDG->setItem(0, 26, new QTableWidgetItem("导轨26"));
    ui->tableDG->setItem(0, 27, new QTableWidgetItem("导轨27"));
    ui->tableDG->setItem(0, 28, new QTableWidgetItem("导轨28"));
    ui->tableDG->setItem(0, 29, new QTableWidgetItem("导轨29"));
    ui->tableDG->setItem(0, 30, new QTableWidgetItem("导轨30"));

    //ui->tableDG->item(0,0)->setForeground(Qt::white);
    ui->tableDG->item(0,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    //ui->tableDG->item(0,0)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,1)->setForeground(Qt::white);
    ui->tableDG->item(0,1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,1)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,1)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,2)->setForeground(Qt::white);
    ui->tableDG->item(0,2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,2)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,2)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,3)->setForeground(Qt::white);
    ui->tableDG->item(0,3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,3)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,3)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,4)->setForeground(Qt::white);
    ui->tableDG->item(0,4)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,4)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,4)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,5)->setForeground(Qt::white);
    ui->tableDG->item(0,5)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,5)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,5)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,6)->setForeground(Qt::white);
    ui->tableDG->item(0,6)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,6)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,6)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,7)->setForeground(Qt::white);
    ui->tableDG->item(0,7)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,7)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,7)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,8)->setForeground(Qt::white);
    ui->tableDG->item(0,8)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,8)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,8)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,9)->setForeground(Qt::white);
    ui->tableDG->item(0,9)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,9)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,9)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,10)->setForeground(Qt::white);
    ui->tableDG->item(0,10)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,10)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,10)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,11)->setForeground(Qt::white);
    ui->tableDG->item(0,11)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,11)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,11)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,12)->setForeground(Qt::white);
    ui->tableDG->item(0,12)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,12)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,12)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,13)->setForeground(Qt::white);
    ui->tableDG->item(0,13)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,13)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,13)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,14)->setForeground(Qt::white);
    ui->tableDG->item(0,14)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,14)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,14)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,15)->setForeground(Qt::white);
    ui->tableDG->item(0,15)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,15)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,15)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,16)->setForeground(Qt::white);
    ui->tableDG->item(0,16)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,16)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,16)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,17)->setForeground(Qt::white);
    ui->tableDG->item(0,17)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,17)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,17)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,18)->setForeground(Qt::white);
    ui->tableDG->item(0,18)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,18)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,18)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,19)->setForeground(Qt::white);
    ui->tableDG->item(0,19)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,19)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,19)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,20)->setForeground(Qt::white);
    ui->tableDG->item(0,20)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,20)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,20)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,21)->setForeground(Qt::white);
    ui->tableDG->item(0,21)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,21)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,21)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,22)->setForeground(Qt::white);
    ui->tableDG->item(0,22)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,22)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,22)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,23)->setForeground(Qt::white);
    ui->tableDG->item(0,23)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,23)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,23)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,24)->setForeground(Qt::white);
    ui->tableDG->item(0,24)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,24)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,24)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,25)->setForeground(Qt::white);
    ui->tableDG->item(0,25)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,25)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,25)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,26)->setForeground(Qt::white);
    ui->tableDG->item(0,26)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,26)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,26)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,27)->setForeground(Qt::white);
    ui->tableDG->item(0,27)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,27)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,27)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,28)->setForeground(Qt::white);
    ui->tableDG->item(0,28)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,28)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,28)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,29)->setForeground(Qt::white);
    ui->tableDG->item(0,29)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,29)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,29)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(0,30)->setForeground(Qt::white);
    ui->tableDG->item(0,30)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(0,30)->setBackground(QColor(10, 53, 79));
    ui->tableDG->item(0,30)->setFont(QFont("Helvetica",10,QFont::Bold));

    ui->tableDG->setItem(1, 0, new QTableWidgetItem("磁芯过温"));
    ui->tableDG->setItem(2, 0, new QTableWidgetItem("电容过温"));
    ui->tableDG->setItem(3, 0, new QTableWidgetItem("线圈过温"));
    ui->tableDG->setItem(4, 0, new QTableWidgetItem("风口过温"));
    ui->tableDG->setItem(5, 0, new QTableWidgetItem("过压故障"));
    ui->tableDG->setItem(6, 0, new QTableWidgetItem("过流故障"));
    ui->tableDG->setItem(7, 0, new QTableWidgetItem("相位>5故障"));
    ui->tableDG->setItem(8, 0, new QTableWidgetItem("— — —"));
    ui->tableDG->setItem(9, 0, new QTableWidgetItem("— — —"));
    ui->tableDG->item(1,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(1,0)->setForeground(Qt::white);
    ui->tableDG->item(1,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(1,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(1,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(2,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(2,0)->setForeground(Qt::white);
    ui->tableDG->item(2,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(2,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(2,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(3,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(3,0)->setForeground(Qt::white);
    ui->tableDG->item(3,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(3,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(3,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(4,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(4,0)->setForeground(Qt::white);
    ui->tableDG->item(4,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(4,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(4,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(5,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(5,0)->setForeground(Qt::white);
    ui->tableDG->item(5,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(5,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(5,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(6,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(6,0)->setForeground(Qt::white);
    ui->tableDG->item(6,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(6,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(6,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(7,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(7,0)->setForeground(Qt::white);
    ui->tableDG->item(7,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(7,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(7,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(8,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(8,0)->setForeground(Qt::white);
    ui->tableDG->item(8,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(8,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(8,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableDG->item(9,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(9,0)->setForeground(Qt::white);
    ui->tableDG->item(9,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableDG->item(9,0)->setBackground(QColor(128, 138, 135));
    ui->tableDG->item(9,0)->setFont(QFont("Helvetica",10,QFont::Bold));

//    for( int i = 0; i < 6; i++ )
//    {
//        ui->tableDG->setItem(i+1, 0, new QTableWidgetItem(QString("(%1,1)").arg(i+1)));
//        ui->tableDG->setItem(i+1, 1, new QTableWidgetItem(QString("(%1,2)").arg(i+1)));
//        ui->tableDG->setItem(i+1, 2, new QTableWidgetItem(QString("(%1,3)").arg(i+1)));
//        ui->tableDG->setItem(i+1, 3, new QTableWidgetItem(QString("(%1,4)").arg(i+1)));
//        ui->tableDG->setItem(i+1, 4, new QTableWidgetItem(QString("(%1,5)").arg(i+1)));
//        ui->tableDG->setItem(i+1, 5, new QTableWidgetItem(QString("(%1,6)").arg(i+1)));

//        ui->tableDG->item(i+1, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//        ui->tableDG->item(i+1, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//        ui->tableDG->item(i+1, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//        ui->tableDG->item(i+1, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//        ui->tableDG->item(i+1, 4)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//        ui->tableDG->item(i+1, 5)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    //    }
}

void MainWindow::InitTableBug()
{
    ui->tableBug->setRowCount(36);   //36行
    ui->tableBug->setColumnCount(3);   //3列
    ui->tableBug->setFrameShape(QFrame::NoFrame); //设置边框
    //ui->tableDG->setFixedSize(1900,300);   //固定大小
    ui->tableBug->verticalHeader()->setVisible(false); //设置垂直头不可见
    ui->tableBug->horizontalHeader()->setVisible(false);   //设置水平头不可见
    ui->tableBug->setSelectionMode(QAbstractItemView::ExtendedSelection); //可多选（Ctrl、Shift、 Ctrl+A都可以）
    ui->tableBug->setSelectionBehavior(QAbstractItemView::SelectRows); //设置选择行为时每次选择一行
    ui->tableBug->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置不可编辑
    //ui->tableDG->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条
    //ui->tableDG->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);  //去掉垂直滚动条
    //ui->tableDG->setFont(QFont("Helvetica"));

//    ui->tableDG->setColumnWidth(0,200);
//    ui->tableDG->setColumnWidth(1,100);
//    ui->tableDG->setColumnWidth(2,100);
//    ui->tableDG->setColumnWidth(3,100);
//    ui->tableDG->setColumnWidth(4,100);
//    ui->tableDG->setColumnWidth(5,100);

    ui->tableBug->setAlternatingRowColors(true);
    //ui->tableDG->setFrameShape(QFrame::NoFrame); //设置边框
    ui->tableBug->setFocusPolicy(Qt::NoFocus); //去除选中虚线框

    QPalette palette;    //调色板
    //palette.setColor(QPalette::Base, QColor(0,255,0));   //基底
    //palette.setColor(QPalette::AlternateBase, QColor(233,245,252));  //交替基底
    //ui->tableDG->setPalette(palette);

    //表头列文本设置
    ui->tableBug->setItem(0, 0, new QTableWidgetItem("模块"));
    ui->tableBug->setItem(0, 1, new QTableWidgetItem("正常"));
    ui->tableBug->setItem(0, 2, new QTableWidgetItem("故障"));
//    ui->tableDG->setItem(0, 3, new QTableWidgetItem("导轨3"));
//    ui->tableDG->setItem(0, 4, new QTableWidgetItem("导轨4"));
//    ui->tableDG->setItem(0, 5, new QTableWidgetItem("导轨5"));
//    ui->tableDG->setItem(0, 6, new QTableWidgetItem("导轨6"));
//    ui->tableDG->setItem(0, 7, new QTableWidgetItem("导轨7"));
//    ui->tableDG->setItem(0, 8, new QTableWidgetItem("导轨8"));
//    ui->tableDG->setItem(0, 9, new QTableWidgetItem("导轨9"));
//    ui->tableDG->setItem(0, 10, new QTableWidgetItem("导轨10"));
//    ui->tableDG->setItem(0, 11, new QTableWidgetItem("导轨11"));
//    ui->tableDG->setItem(0, 12, new QTableWidgetItem("导轨12"));
//    ui->tableDG->setItem(0, 13, new QTableWidgetItem("导轨13"));
//    ui->tableDG->setItem(0, 14, new QTableWidgetItem("导轨14"));
//    ui->tableDG->setItem(0, 15, new QTableWidgetItem("导轨15"));
//    ui->tableDG->setItem(0, 16, new QTableWidgetItem("导轨16"));
//    ui->tableDG->setItem(0, 17, new QTableWidgetItem("导轨17"));
//    ui->tableDG->setItem(0, 18, new QTableWidgetItem("导轨18"));
//    ui->tableDG->setItem(0, 19, new QTableWidgetItem("导轨19"));
//    ui->tableDG->setItem(0, 20, new QTableWidgetItem("导轨20"));
//    ui->tableDG->setItem(0, 21, new QTableWidgetItem("导轨21"));
//    ui->tableDG->setItem(0, 22, new QTableWidgetItem("导轨22"));
//    ui->tableDG->setItem(0, 23, new QTableWidgetItem("导轨23"));
//    ui->tableDG->setItem(0, 24, new QTableWidgetItem("导轨24"));
//    ui->tableDG->setItem(0, 25, new QTableWidgetItem("导轨25"));
//    ui->tableDG->setItem(0, 26, new QTableWidgetItem("导轨26"));
//    ui->tableDG->setItem(0, 27, new QTableWidgetItem("导轨27"));
//    ui->tableDG->setItem(0, 28, new QTableWidgetItem("导轨28"));
//    ui->tableDG->setItem(0, 29, new QTableWidgetItem("导轨29"));
//    ui->tableDG->setItem(0, 30, new QTableWidgetItem("导轨30"));

    //ui->tableDG->item(0,0)->setForeground(Qt::white);
    ui->tableBug->item(0,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    //ui->tableDG->item(0,0)->setBackground(QColor(10, 53, 79));
    ui->tableBug->item(0,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(0,1)->setForeground(Qt::white);
    ui->tableBug->item(0,1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(0,1)->setBackground(QColor(10, 53, 79));
    ui->tableBug->item(0,1)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(0,2)->setForeground(Qt::white);
    ui->tableBug->item(0,2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(0,2)->setBackground(QColor(10, 53, 79));
    ui->tableBug->item(0,2)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,3)->setForeground(Qt::white);
//    ui->tableDG->item(0,3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,3)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,3)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,4)->setForeground(Qt::white);
//    ui->tableDG->item(0,4)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,4)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,4)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,5)->setForeground(Qt::white);
//    ui->tableDG->item(0,5)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,5)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,5)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,6)->setForeground(Qt::white);
//    ui->tableDG->item(0,6)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,6)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,6)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,7)->setForeground(Qt::white);
//    ui->tableDG->item(0,7)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,7)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,7)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,8)->setForeground(Qt::white);
//    ui->tableDG->item(0,8)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,8)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,8)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,9)->setForeground(Qt::white);
//    ui->tableDG->item(0,9)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,9)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,9)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,10)->setForeground(Qt::white);
//    ui->tableDG->item(0,10)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,10)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,10)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,11)->setForeground(Qt::white);
//    ui->tableDG->item(0,11)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,11)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,11)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,12)->setForeground(Qt::white);
//    ui->tableDG->item(0,12)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,12)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,12)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,13)->setForeground(Qt::white);
//    ui->tableDG->item(0,13)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,13)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,13)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,14)->setForeground(Qt::white);
//    ui->tableDG->item(0,14)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,14)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,14)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,15)->setForeground(Qt::white);
//    ui->tableDG->item(0,15)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,15)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,15)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,16)->setForeground(Qt::white);
//    ui->tableDG->item(0,16)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,16)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,16)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,17)->setForeground(Qt::white);
//    ui->tableDG->item(0,17)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,17)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,17)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,18)->setForeground(Qt::white);
//    ui->tableDG->item(0,18)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,18)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,18)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,19)->setForeground(Qt::white);
//    ui->tableDG->item(0,19)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,19)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,19)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,20)->setForeground(Qt::white);
//    ui->tableDG->item(0,20)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,20)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,20)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,21)->setForeground(Qt::white);
//    ui->tableDG->item(0,21)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,21)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,21)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,22)->setForeground(Qt::white);
//    ui->tableDG->item(0,22)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,22)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,22)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,23)->setForeground(Qt::white);
//    ui->tableDG->item(0,23)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,23)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,23)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,24)->setForeground(Qt::white);
//    ui->tableDG->item(0,24)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,24)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,24)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,25)->setForeground(Qt::white);
//    ui->tableDG->item(0,25)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,25)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,25)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,26)->setForeground(Qt::white);
//    ui->tableDG->item(0,26)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,26)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,26)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,27)->setForeground(Qt::white);
//    ui->tableDG->item(0,27)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,27)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,27)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,28)->setForeground(Qt::white);
//    ui->tableDG->item(0,28)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,28)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,28)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,29)->setForeground(Qt::white);
//    ui->tableDG->item(0,29)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,29)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,29)->setFont(QFont("Helvetica",10,QFont::Bold));
//    ui->tableDG->item(0,30)->setForeground(Qt::white);
//    ui->tableDG->item(0,30)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//    ui->tableDG->item(0,30)->setBackground(QColor(10, 53, 79));
//    ui->tableDG->item(0,30)->setFont(QFont("Helvetica",10,QFont::Bold));

    ui->tableBug->setItem(1, 0, new QTableWidgetItem("车辆电池"));
    ui->tableBug->setItem(2, 0, new QTableWidgetItem("车载DCDC"));
    ui->tableBug->setItem(3, 0, new QTableWidgetItem("逆变器1"));
    ui->tableBug->setItem(4, 0, new QTableWidgetItem("逆变器2"));
    ui->tableBug->setItem(5, 0, new QTableWidgetItem("逆变器3"));
    ui->tableBug->setItem(6, 0, new QTableWidgetItem("导轨1"));
    ui->tableBug->setItem(7, 0, new QTableWidgetItem("导轨2"));
    ui->tableBug->setItem(8, 0, new QTableWidgetItem("导轨3"));
    ui->tableBug->setItem(9, 0, new QTableWidgetItem("导轨4"));
    ui->tableBug->setItem(10, 0, new QTableWidgetItem("导轨5"));
    ui->tableBug->setItem(11, 0, new QTableWidgetItem("导轨6"));
    ui->tableBug->setItem(12, 0, new QTableWidgetItem("导轨7"));
    ui->tableBug->setItem(13, 0, new QTableWidgetItem("导轨8"));
    ui->tableBug->setItem(14, 0, new QTableWidgetItem("导轨9"));
    ui->tableBug->setItem(15, 0, new QTableWidgetItem("导轨10"));
    ui->tableBug->setItem(16, 0, new QTableWidgetItem("导轨11"));
    ui->tableBug->setItem(17, 0, new QTableWidgetItem("导轨12"));
    ui->tableBug->setItem(18, 0, new QTableWidgetItem("导轨13"));
    ui->tableBug->setItem(19, 0, new QTableWidgetItem("导轨14"));
    ui->tableBug->setItem(20, 0, new QTableWidgetItem("导轨15"));
    ui->tableBug->setItem(21, 0, new QTableWidgetItem("导轨16"));
    ui->tableBug->setItem(22, 0, new QTableWidgetItem("导轨17"));
    ui->tableBug->setItem(23, 0, new QTableWidgetItem("导轨18"));
    ui->tableBug->setItem(24, 0, new QTableWidgetItem("导轨19"));
    ui->tableBug->setItem(25, 0, new QTableWidgetItem("导轨20"));
    ui->tableBug->setItem(26, 0, new QTableWidgetItem("导轨21"));
    ui->tableBug->setItem(27, 0, new QTableWidgetItem("导轨22"));
    ui->tableBug->setItem(28, 0, new QTableWidgetItem("导轨23"));
    ui->tableBug->setItem(29, 0, new QTableWidgetItem("导轨24"));
    ui->tableBug->setItem(30, 0, new QTableWidgetItem("导轨25"));
    ui->tableBug->setItem(31, 0, new QTableWidgetItem("导轨26"));
    ui->tableBug->setItem(32, 0, new QTableWidgetItem("导轨27"));
    ui->tableBug->setItem(33, 0, new QTableWidgetItem("导轨28"));
    ui->tableBug->setItem(34, 0, new QTableWidgetItem("导轨29"));
    ui->tableBug->setItem(35, 0, new QTableWidgetItem("导轨30"));
    ui->tableBug->item(1,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    //ui->tableDG->item(1,0)->setForeground(Qt::white);
    ui->tableBug->item(1,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(1,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(1,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(2,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(2,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(2,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(2,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(3,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(3,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(3,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(3,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(4,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(4,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(4,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(4,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(5,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(5,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(5,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(5,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(6,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(6,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(6,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(6,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(7,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(7,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(7,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(7,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(8,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(8,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(8,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(8,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(9,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(9,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(9,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(9,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(10,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(10,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(10,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(10,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(11,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(11,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(11,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(11,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(12,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(12,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(12,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(12,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(13,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(13,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(13,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(13,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(14,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(14,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(14,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(14,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(15,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(15,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(15,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(15,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(16,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(16,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(16,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(16,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(17,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(17,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(17,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(17,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(18,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(18,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(18,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(18,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(19,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(19,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(19,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(19,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(20,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(20,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(20,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(20,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(21,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(21,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(21,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(21,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(22,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(22,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(22,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(22,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(23,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(23,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(23,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(23,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(24,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(24,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(24,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(24,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(25,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(25,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(25,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(25,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(26,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(26,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(26,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(26,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(27,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(27,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(27,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(27,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(28,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(28,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(28,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(28,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(29,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(29,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(29,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(29,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(30,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(30,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(30,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(30,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(31,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(31,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(31,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(31,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(32,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(32,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(32,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(32,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(33,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(33,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(33,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(33,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(34,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(34,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(34,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(34,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(35,0)->setFont(QFont("Helvetica",10,QFont::Bold));
    ui->tableBug->item(35,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->tableBug->item(35,0)->setBackground(QColor(128, 138, 135));
    ui->tableBug->item(35,0)->setFont(QFont("Helvetica",10,QFont::Bold));
}


void MainWindow::signCar1(int num)
{
    if(num == 1)
    {
        ui->car2->setStyleSheet("border-image: url()");
    }
    ui->car2->setStyleSheet("border-image: url()");
    ui->car3->setStyleSheet("border-image: url()");
    ui->car4->setStyleSheet("border-image: url()");
    ui->car5->setStyleSheet("border-image: url()");
    ui->car6->setStyleSheet("border-image: url()");
    ui->car7->setStyleSheet("border-image: url()");
    ui->car8->setStyleSheet("border-image: url()");
    ui->car9->setStyleSheet("border-image: url()");
    ui->car10->setStyleSheet("border-image: url()");
    ui->car11->setStyleSheet("border-image: url()");
    ui->car12->setStyleSheet("border-image: url()");
    ui->car13->setStyleSheet("border-image: url()");
    ui->car14->setStyleSheet("border-image: url()");
    ui->car15->setStyleSheet("border-image: url()");
    ui->car16->setStyleSheet("border-image: url()");
    ui->car17->setStyleSheet("border-image: url()");
    ui->car18->setStyleSheet("border-image: url()");
    ui->car19->setStyleSheet("border-image: url()");
    ui->car20->setStyleSheet("border-image: url()");
    ui->car21->setStyleSheet("border-image: url()");
    ui->car22->setStyleSheet("border-image: url()");
    ui->car23->setStyleSheet("border-image: url()");
    ui->car24->setStyleSheet("border-image: url()");
    ui->car25->setStyleSheet("border-image: url()");
    ui->car26->setStyleSheet("border-image: url()");
    ui->car27->setStyleSheet("border-image: url()");
    ui->car28->setStyleSheet("border-image: url()");
    ui->car29->setStyleSheet("border-image: url()");
    ui->car30->setStyleSheet("border-image: url()");
}


void MainWindow::initForm()
{
    this->setProperty("form", true);
    this->setProperty("canMove", true);
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);

    //IconHelper::Instance()->setIcon(ui->labIco, QChar(0xf073), 30);
    IconHelper::Instance()->setIcon(ui->btnMenu_Min, QChar(0xf068));
    IconHelper::Instance()->setIcon(ui->btnMenu_Max, QChar(0xf067));
    IconHelper::Instance()->setIcon(ui->btnMenu_Close, QChar(0xf00d));

    //ui->widgetMenu->setVisible(false);
    ui->widgetTitle->setProperty("form", "title");
    ui->widgetTop->setProperty("nav", "top");
//    ui->labTitle->setFont(QFont("Microsoft Yahei", 25));
//    ui->labTitle->setFont(QFont("Segoe UI Black", 25));
    this->setWindowTitle(ui->labTitle->text());

    //ui->stackedWidget->setStyleSheet("QLabel{font:60pt;}");

    QStringList strList1;
    strList1<<"发射导轨1"<<"发射导轨2"<<"发射导轨3"<<"发射导轨4"<<"发射导轨5"<<"发射导轨6"<<"发射导轨7"<<"发射导轨8"<<"发射导轨9"<<"发射导轨10"<<"发射导轨11"<<"发射导轨12"<<"发射导轨13"<<"发射导轨14"<<"发射导轨15"<<"发射导轨16"<<"发射导轨17"<<"发射导轨18"<<"发射导轨19"<<"发射导轨20"<<"发射导轨21"<<"发射导轨22"<<"发射导轨23"<<"发射导轨24"<<"发射导轨25"<<"发射导轨26"<<"发射导轨27"<<"发射导轨28"<<"发射导轨29"<<"发射导轨30";
    ui->navProgress->setMaxStep(30);
    QStringList strList2;
    strList2<<""<<""<<""<<""<<"";
    ui->navProgress->setTopInfo(strList2);
    ui->navProgress->setCurrentBackground(QColor("#696969"));

    QStringList strList3;
    strList3<<"系统数据"<<"逆变数据"<<"车辆数据";
    ui->comboBox->addItems(strList3);
    ui->comboBox_2->addItems(strList1);

    QStringList strList4;
    strList4<<"DCDC数据"<<"电池数据";
    ui->comboBox_3->addItems(strList4);

    QStringList strList5;
    strList5<<"温度"<<"健康度";
    ui->comboBox_4->addItems(strList5);

    QSize icoSize(32, 32);
    int icoWidth = 85;

    //设置顶部导航按钮
    QList<QToolButton *> tbtns = ui->widgetTop->findChildren<QToolButton *>();
    foreach (QToolButton *btn, tbtns) {
        btn->setIconSize(icoSize);
        btn->setMinimumWidth(icoWidth);
        btn->setCheckable(true);
        connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick()));
    }    

    ui->btnMain->click();

    //ui->widgetLeftMain->setProperty("flag", "left");
    //ui->widgetLeftConfig->setProperty("flag", "left");
    ui->page1->setStyleSheet(QString("QWidget[flag=\"left\"] QAbstractButton{min-height:%1px;max-height:%1px;}").arg(60));
    ui->page2->setStyleSheet(QString("QWidget[flag=\"left\"] QAbstractButton{min-height:%1px;max-height:%1px;}").arg(60));

    ui->lightNB_gy->setGray();
    ui->lightNB_gl->setGray();
    ui->lightNB_dl->setGray();
    ui->lightNB_sx->setGray();
    ui->lightNB_temA->setGray();
    ui->lightNB_temB->setGray();
    ui->lightNB_qdA->setGray();
    ui->lightNB_qdB->setGray();
    ui->lightNB_pfc->setGray();
    ui->lightNB_xfdz->setGray();

    ui->lightNB2_gy->setGray();
    ui->lightNB2_gl->setGray();
    ui->lightNB2_dl->setGray();
    ui->lightNB2_sx->setGray();
    ui->lightNB2_temA->setGray();
    ui->lightNB2_temB->setGray();
    ui->lightNB2_qdA->setGray();
    ui->lightNB2_qdB->setGray();
    ui->lightNB2_pfc->setGray();
    ui->lightNB2_xfdz->setGray();

    ui->lightNB3_gy->setGray();
    ui->lightNB3_gl->setGray();
    ui->lightNB3_dl->setGray();
    ui->lightNB3_sx->setGray();
    ui->lightNB3_temA->setGray();
    ui->lightNB3_temB->setGray();
    ui->lightNB3_qdA->setGray();
    ui->lightNB3_qdB->setGray();
    ui->lightNB3_pfc->setGray();
    ui->lightNB3_xfdz->setGray();

    ui->lightDC_scgy->setGray();
    ui->lightDC_scgl->setGray();
    ui->lightDC_srgy->setGray();
    ui->lightDC_sggw->setGray();
    ui->lightDC_xggw->setGray();
    ui->lightDC_dggw->setGray();

//    ui->progressWater->setWaterDensity(4);
//    ui->progressWater->setReverse(true);
    ui->progressWater->setValue(75);
    ui->progressWater_2->setValue(75);
    ui->progressPercent->setValue(80);
    ui->progressPercent_2->setValue(80);

    ui->progressArc->setPercent(false);
    ui->progressArc->setTitleColor(Qt::white);
    ui->progressArc->setTitle("单位:℃");
    ui->progressArc_2->setPercent(false);
    ui->progressArc_2->setTitleColor(Qt::white);
    ui->progressArc_2->setTitle("单位:℃");

    ui->progressArc_6->setPercent(false);
    ui->progressArc_6->setTitleColor(Qt::white);
    ui->progressArc_6->setTitle("单位:℃");
    ui->progressArc_7->setPercent(false);
    ui->progressArc_7->setTitleColor(Qt::white);
    ui->progressArc_7->setTitle("单位:℃");

    ui->progressArc_8->setPercent(false);
    ui->progressArc_8->setTitleColor(Qt::white);
    ui->progressArc_8->setTitle("单位:kW");
    ui->progressArc_9->setPercent(false);
    ui->progressArc_9->setTitleColor(Qt::white);
    ui->progressArc_9->setTitle("单位:kW");

    ui->progressArc_3->setPercent(false);
    ui->progressArc_3->setTitleColor(Qt::white);
    ui->progressArc_3->setTitle("单位:℃");
    ui->progressArc_4->setPercent(false);
    ui->progressArc_4->setTitleColor(Qt::white);
    ui->progressArc_4->setTitle("单位:℃");

    ui->ArcDC_inW->setPercent(false);
    ui->ArcDC_inW->setTitleColor(Qt::white);
    ui->ArcDC_inW->setTitle("单位:kW");
    ui->ArcDC_putW->setPercent(false);
    ui->ArcDC_putW->setTitleColor(Qt::white);
    ui->ArcDC_putW->setTitle("单位:kW");

    ui->gaugeSimple->setRange(0,1000);
    ui->gaugeSimple_2->setRange(0,500);
}

void MainWindow::buttonClick()
{
    QToolButton *b = (QToolButton *)sender();
    QString name = b->text();

    QList<QToolButton *> tbtns = ui->widgetTop->findChildren<QToolButton *>();
    foreach (QToolButton *btn, tbtns) {
        if (btn == b) {
            btn->setChecked(true);
        } else {
            btn->setChecked(false);
        }
    }

    if (name == "综合监测") {
        ui->stackedWidget->setCurrentIndex(0);
    } else if (name == "逆变监测") {
        ui->stackedWidget->setCurrentIndex(1);
    } else if (name == "发射导轨") {
        ui->stackedWidget->setCurrentIndex(2);
    } else if (name == "车载接收") {
        ui->stackedWidget->setCurrentIndex(3);
    } else if (name == "故障查询") {
        ui->stackedWidget->setCurrentIndex(4);
    } else if (name == "历史数据") {
        ui->stackedWidget->setCurrentIndex(5);
    } else if (name == "用户退出") {
        exit(0);
    }
}

void MainWindow::buttonClick1()
{
    QToolButton *b = (QToolButton *)sender();
    QString name = b->text();

    QList<QToolButton *> tbtns = ui->widget_2->findChildren<QToolButton *>();
    foreach (QToolButton *btn, tbtns) {
        if (btn == b) {
            btn->setChecked(true);
        } else {
            btn->setChecked(false);
        }
    }

    if (name == "主界面") {

    } else if (name == "系统设置") {
        //ui->stackedWidget->setCurrentIndex(1);
    }
}

void MainWindow::initLeftMain()
{
//    pixCharMain << 0xf030 << 0xf03e << 0xf247;
//    btnsMain << ui->tbtnMain1 << ui->tbtnMain2 << ui->tbtnMain3;

//    int count = btnsMain.count();
//    for (int i = 0; i < count; i++) {
//        btnsMain.at(i)->setCheckable(true);
//        btnsMain.at(i)->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
//        connect(btnsMain.at(i), SIGNAL(clicked(bool)), this, SLOT(leftMainClick()));
//    }

//    IconHelper::Instance()->setStyle(ui->widgetLeftMain, btnsMain, pixCharMain, 15, 35, 25, "left", 4);

//    ui->tbtnMain1->click();
}

void MainWindow::initLeftConfig()
{
//    pixCharConfig << 0xf031 << 0xf036 << 0xf249 << 0xf055 << 0xf05a << 0xf249;
//    btnsConfig << ui->tbtnConfig1 << ui->tbtnConfig2 << ui->tbtnConfig3 << ui->tbtnConfig4 << ui->tbtnConfig5 << ui->tbtnConfig6;

//    int count = btnsConfig.count();
//    for (int i = 0; i < count; i++) {
//        btnsConfig.at(i)->setCheckable(true);
//        btnsConfig.at(i)->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
//        connect(btnsConfig.at(i), SIGNAL(clicked(bool)), this, SLOT(leftConfigClick()));
//    }

//    IconHelper::Instance()->setStyle(ui->widgetLeftConfig, btnsConfig, pixCharConfig, 10, 20, 15, "left", 5);

//    ui->tbtnConfig1->click();
}

void MainWindow::leftMainClick()
{
    QToolButton *b = (QToolButton *)sender();
    QString name = b->text();

    int count = btnsMain.count();
    for (int i = 0; i < count; i++) {
        if (btnsMain.at(i) == b) {
            btnsMain.at(i)->setChecked(true);
            btnsMain.at(i)->setIcon(QIcon(IconHelper::Instance()->getPixmap(btnsMain.at(i), false)));
        } else {
            btnsMain.at(i)->setChecked(false);
            btnsMain.at(i)->setIcon(QIcon(IconHelper::Instance()->getPixmap(btnsMain.at(i), true)));
        }
    }

    //ui->lab1->setText(name);
}

void MainWindow::leftConfigClick()
{
    QToolButton *b = (QToolButton *)sender();
    QString name = b->text();

    int count = btnsConfig.count();
    for (int i = 0; i < count; i++) {
        if (btnsConfig.at(i) == b) {
            btnsConfig.at(i)->setChecked(true);
            btnsConfig.at(i)->setIcon(QIcon(IconHelper::Instance()->getPixmap(btnsConfig.at(i), false)));
        } else {
            btnsConfig.at(i)->setChecked(false);
            btnsConfig.at(i)->setIcon(QIcon(IconHelper::Instance()->getPixmap(btnsConfig.at(i), true)));
        }
    }
    //ui->lab2->setText(name);
}

void MainWindow::on_btnMenu_Min_clicked()
{
    showMinimized();
}

void MainWindow::on_btnMenu_Max_clicked()
{
    static bool max = false;
    static QRect location = this->geometry();

    if (max) {
        this->setGeometry(location);
    } else {
        location = this->geometry();
        this->setGeometry(qApp->primaryScreen()->geometry());
    }

    this->setProperty("canMove", max);
    max = !max;
}

void MainWindow::on_btnMenu_Close_clicked()
{
    close();
}

void MainWindow::on_btnHelp_4_clicked()
{
    conform->show();
}

/************************** tcp连接函数 *****************************/
void MainWindow::mNewConnection1()
{
    //与客户端连接；
    tcpsocket1 = tcpServer1->nextPendingConnection();
    QString ipAddr = tcpsocket1->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    quint16 port = tcpsocket1->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer1->start();
    h_timer1->start();
    emit tcpcon();
    bol1 = true;
    connect(tcpsocket1,SIGNAL(readyRead()),this,SLOT(receiveMessage1()));
    connect(tcpsocket1, SIGNAL(disconnected()),this, SLOT(onDisconnected1()));
    connect(tcpsocket1,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer1->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }else if(socketList.count() == 1)
    {

    }
}

void MainWindow::mNewConnection2()
{
    //与客户端连接；
    tcpsocket2 = tcpServer2->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket2->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket2->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer2->start();
    h_timer2->start();
    emit tcpcon();
    bol2 = true;
    connect(tcpsocket2,SIGNAL(readyRead()),this,SLOT(receiveMessage2()));
    connect(tcpsocket2, SIGNAL(disconnected()),this, SLOT(onDisconnected2()));
    connect(tcpsocket2,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer2->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection3()
{
    //与客户端连接；
    tcpsocket3 = tcpServer3->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket3->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    quint16 port = tcpsocket3->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer3->start();
    h_timer3->start();
    emit tcpcon();
    bol3 = true;
    connect(tcpsocket3,SIGNAL(readyRead()),this,SLOT(receiveMessage3()));
    connect(tcpsocket3, SIGNAL(disconnected()),this, SLOT(onDisconnected3()));
    connect(tcpsocket3,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer3->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection4()
{
    //与客户端连接；
    tcpsocket4 = tcpServer4->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket4->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket4->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer4->start();
    h_timer4->start();
    emit tcpcon();
    bol4 = true;
    connect(tcpsocket4,SIGNAL(readyRead()),this,SLOT(receiveMessage4()));
    connect(tcpsocket4, SIGNAL(disconnected()),this, SLOT(onDisconnected4()));
    connect(tcpsocket4,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer4->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection5()
{
    //与客户端连接；
    tcpsocket5 = tcpServer5->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket5->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket5->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer5->start();
    h_timer5->start();
    emit tcpcon();
    bol5 = true;
    connect(tcpsocket5,SIGNAL(readyRead()),this,SLOT(receiveMessage5()));
    connect(tcpsocket5, SIGNAL(disconnected()),this, SLOT(onDisconnected5()));
    connect(tcpsocket5,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer5->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection6()
{
    //与客户端连接；
    tcpsocket6 = tcpServer6->nextPendingConnection();

    //打印ip地址；
    QString ipAddr = tcpsocket6->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket6->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer6->start();
    h_timer6->start();
    emit tcpcon();
    bol6 = true;
    connect(tcpsocket6,SIGNAL(readyRead()),this,SLOT(receiveMessage6()));
    connect(tcpsocket6, SIGNAL(disconnected()),this, SLOT(onDisconnected6()));
    connect(tcpsocket6,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer6->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection7()
{
    //与客户端连接；
    tcpsocket7 = tcpServer7->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket7->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket7->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer7->start();
    h_timer7->start();
    emit tcpcon();
    bol7 = true;
    connect(tcpsocket7,SIGNAL(readyRead()),this,SLOT(receiveMessage7()));
    connect(tcpsocket7, SIGNAL(disconnected()),this, SLOT(onDisconnected7()));
    connect(tcpsocket7,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer7->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection8()
{
    //与客户端连接；
    tcpsocket8 = tcpServer8->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket8->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket8->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer8->start();
    h_timer8->start();
    emit tcpcon();
    bol8 = true;
    connect(tcpsocket8,SIGNAL(readyRead()),this,SLOT(receiveMessage8()));
    connect(tcpsocket8, SIGNAL(disconnected()),this, SLOT(onDisconnected8()));
    connect(tcpsocket8,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer8->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

void MainWindow::mNewConnection9()
{
    //与客户端连接；
    tcpsocket9 = tcpServer9->nextPendingConnection();
    //打印ip地址；
    QString ipAddr = tcpsocket9->peerAddress().toString();
    QString ip = ipAddr.mid(7,13);
    QString curTime= QDateTime::currentDateTime().toString("yyyy:MM:dd hh:mm:ss");
    //打印port地址；
    quint16 port = tcpsocket9->peerPort();
    qDebug()<<curTime+"客户端连接--port:"+port;
    m_timer9->start();
    h_timer9->start();
    emit tcpcon();
    bol9 = true;
    connect(tcpsocket9,SIGNAL(readyRead()),this,SLOT(receiveMessage9()));
    connect(tcpsocket9, SIGNAL(disconnected()),this, SLOT(onDisconnected9()));
    connect(tcpsocket9,SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this,SLOT(mStateChanged(QAbstractSocket::SocketState)));
    QList <QTcpSocket*> socketList = tcpServer9->findChildren<QTcpSocket*>();
    if(socketList.count() == 0)
    {
        qDebug()<<"客户端断开";
        return;
    }
}

/************************** tcp数据接收函数 *****************************/
void MainWindow::receiveMessage1()
{
    count1 = 0;
    QByteArray rec = tcpsocket1->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer1->stop();
        sendDataI1();
        emit sig_track1Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD1();
        emit sig_track1Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW1();
        emit sig_track1Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ1();
        emit sig_track1Data(data);
    }
}

void MainWindow::receiveMessage2()
{
    count2 = 0;
    QByteArray rec = tcpsocket2->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer2->stop();
        sendDataI2();
        emit sig_track2Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD2();
        emit sig_track2Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW2();
        emit sig_track2Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ2();
        emit sig_track2Data(data);
    }
}

void MainWindow::receiveMessage3()
{
    count3 = 0;
    QByteArray rec = tcpsocket3->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer3->stop();
        sendDataI3();
        emit sig_track3Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD3();
        emit sig_track3Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW3();
        emit sig_track3Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ3();
        emit sig_track3Data(data);
    }
}

void MainWindow::receiveMessage4()
{
    count4 = 0;
    QByteArray rec = tcpsocket4->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer4->stop();
        sendDataI4();
        emit sig_track4Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD4();
        emit sig_track4Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW4();
        emit sig_track4Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ4();
        emit sig_track4Data(data);
    }
}

void MainWindow::receiveMessage5()
{
    count5 = 0;
    QByteArray rec = tcpsocket5->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer5->stop();
        sendDataI5();
        emit sig_track5Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD5();
        emit sig_track5Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW5();
        emit sig_track5Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ5();
        emit sig_track5Data(data);
    }
}

void MainWindow::receiveMessage6()
{
    count6 = 0;
    QByteArray rec = tcpsocket6->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer6->stop();
        sendDataI6();
        emit sig_track6Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD6();
        emit sig_track6Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW6();
        emit sig_track6Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ6();
        emit sig_track6Data(data);
    }
}

void MainWindow::receiveMessage7()
{
    count7 = 0;
    QByteArray rec = tcpsocket7->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer7->stop();
        sendDataI7();
        emit sig_track7Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD7();
        emit sig_track7Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW7();
        emit sig_track7Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ7();
        emit sig_track7Data(data);
    }
}

void MainWindow::receiveMessage8()
{
    count8 = 0;
    QByteArray rec = tcpsocket8->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer8->stop();
        sendDataI8();
        emit sig_track1Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD8();
        emit sig_track8Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW8();
        emit sig_track8Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ8();
        emit sig_track8Data(data);
    }
}

void MainWindow::receiveMessage9()
{
    count9 = 0;
    QByteArray rec = tcpsocket9->readAll();
    QString data=QString(rec.toHex().toUpper());
    if(data.mid(2,2) == "01")
    {
        m_timer9->stop();
        sendDataI9();
        emit sig_track9Data(data);
    }
    if(data.mid(2,2) == "02")
    {
        sendDataD9();
        emit sig_track9Data(data);
    }
    if(data.mid(2,2) == "03")
    {
        sendDataW9();
        emit sig_track9Data(data);
    }
    if(data.mid(2,2) == "04")
    {
        sendDataQ9();
        emit sig_track9Data(data);
    }
}

/************************** tcp断开接函数 *****************************/
void MainWindow::onDisconnected1()
{

}

void MainWindow::onDisconnected2()
{

}

void MainWindow::onDisconnected3()
{

}

void MainWindow::onDisconnected4()
{

}

void MainWindow::onDisconnected5()
{

}

void MainWindow::onDisconnected6()
{

}

void MainWindow::onDisconnected7()
{

}

void MainWindow::onDisconnected8()
{

}

void MainWindow::onDisconnected9()
{

}

/************************** 心跳包函数 *****************************/
void MainWindow::doheart1()
{
    count1++;
    if(count1>4)
    {
        m_timer1->start();
    }
}

void MainWindow::doheart2()
{
    count2++;
    if(count2>4)
    {
        m_timer2->start();
    }
}

void MainWindow::doheart3()
{
    count3++;
    if(count3>4)
    {
        m_timer3->start();
    }
}

void MainWindow::doheart4()
{
    count4++;
    if(count4>4)
    {
        m_timer4->start();
    }
}

void MainWindow::doheart5()
{
    count5++;
    if(count5>4)
    {
        m_timer5->start();
    }
}

void MainWindow::doheart6()
{
    count6++;
    if(count6>4)
    {
        m_timer6->start();
    }
}
void MainWindow::doheart7()
{
    count7++;
    if(count7>4)
    {
        m_timer7->start();
    }
}
void MainWindow::doheart8()
{
    count8++;
    if(count8>4)
    {
        m_timer8->start();
    }
}
void MainWindow::doheart9()
{
    count9++;
    if(count9>4)
    {
        m_timer9->start();
    }
}

/************************** 读取PLC输出状态Q *****************************/
void MainWindow::sendDataQ1()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket1->write(byteAry);
    tcpsocket1->flush();
}

void MainWindow::sendDataQ2()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket2->write(byteAry);
    tcpsocket2->flush();
}

void MainWindow::sendDataQ3()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket3->write(byteAry);
    tcpsocket3->flush();
}

void MainWindow::sendDataQ4()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket4->write(byteAry);
    tcpsocket4->flush();
}

void MainWindow::sendDataQ5()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket5->write(byteAry);
    tcpsocket5->flush();
}

void MainWindow::sendDataQ6()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket6->write(byteAry);
    tcpsocket6->flush();
}

void MainWindow::sendDataQ7()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket7->write(byteAry);
    tcpsocket7->flush();
}

void MainWindow::sendDataQ8()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket8->write(byteAry);
    tcpsocket8->flush();
}

void MainWindow::sendDataQ9()
{
    QByteArray bytes1 = hexStringToByteArray(dataQ);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataQ.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket9->write(byteAry);
    tcpsocket9->flush();
}

/************************** 读取PLC输出状态I *****************************/
void MainWindow::sendDataI1()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket1->write(byteAry);
    tcpsocket1->flush();
}

void MainWindow::sendDataI2()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket2->write(byteAry);
    tcpsocket2->flush();
}

void MainWindow::sendDataI3()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket3->write(byteAry);
    tcpsocket3->flush();
}

void MainWindow::sendDataI4()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket4->write(byteAry);
    tcpsocket4->flush();
}

void MainWindow::sendDataI5()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket5->write(byteAry);
    tcpsocket5->flush();
}

void MainWindow::sendDataI6()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket6->write(byteAry);
    tcpsocket6->flush();
}

void MainWindow::sendDataI7()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket7->write(byteAry);
    tcpsocket7->flush();
}

void MainWindow::sendDataI8()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket8->write(byteAry);
    tcpsocket8->flush();
}

void MainWindow::sendDataI9()
{
    QByteArray bytes1 = hexStringToByteArray(dataI);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataI.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket9->write(byteAry);
    tcpsocket9->flush();
}

/************************** 读取PLC电压、电流等 *****************************/
void MainWindow::sendDataD1()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket1->write(byteAry);
    tcpsocket1->flush();
}

void MainWindow::sendDataD2()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket2->write(byteAry);
    tcpsocket2->flush();
}

void MainWindow::sendDataD3()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket3->write(byteAry);
    tcpsocket3->flush();
}

void MainWindow::sendDataD4()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket4->write(byteAry);
    tcpsocket4->flush();
}

void MainWindow::sendDataD5()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket5->write(byteAry);
    tcpsocket5->flush();
}

void MainWindow::sendDataD6()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket6->write(byteAry);
    tcpsocket6->flush();
}

void MainWindow::sendDataD7()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket7->write(byteAry);
    tcpsocket7->flush();
}

void MainWindow::sendDataD8()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket8->write(byteAry);
    tcpsocket8->flush();
}

void MainWindow::sendDataD9()
{
    QByteArray bytes1 = hexStringToByteArray(dataD);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataD.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket9->write(byteAry);
    tcpsocket9->flush();
}

/************************** 读取PLC温度数据 *****************************/
void MainWindow::sendDataW1()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket1->write(byteAry);
    tcpsocket1->flush();
}

void MainWindow::sendDataW2()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket2->write(byteAry);
    tcpsocket2->flush();
}

void MainWindow::sendDataW3()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket3->write(byteAry);
    tcpsocket3->flush();
}

void MainWindow::sendDataW4()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket4->write(byteAry);
    tcpsocket4->flush();
}

void MainWindow::sendDataW5()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket5->write(byteAry);
    tcpsocket5->flush();
}

void MainWindow::sendDataW6()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket6->write(byteAry);
    tcpsocket6->flush();
}

void MainWindow::sendDataW7()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket7->write(byteAry);
    tcpsocket7->flush();
}

void MainWindow::sendDataW8()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket8->write(byteAry);
    tcpsocket8->flush();
}

void MainWindow::sendDataW9()
{
    QByteArray bytes1 = hexStringToByteArray(dataW);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataW.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket9->write(byteAry);
    tcpsocket9->flush();
}

/************************** 发射导轨开关控制 *****************************/
void MainWindow::sendDataK1()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket1->write(byteAry);
    tcpsocket1->flush();
}

void MainWindow::sendDataK2()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket2->write(byteAry);
    tcpsocket2->flush();
}

void MainWindow::sendDataK3()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket3->write(byteAry);
    tcpsocket3->flush();
}

void MainWindow::sendDataK4()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket4->write(byteAry);
    tcpsocket4->flush();
}

void MainWindow::sendDataK5()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket5->write(byteAry);
    tcpsocket5->flush();
}

void MainWindow::sendDataK6()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket6->write(byteAry);
    tcpsocket6->flush();
}

void MainWindow::sendDataK7()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket7->write(byteAry);
    tcpsocket7->flush();
}

void MainWindow::sendDataK8()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket8->write(byteAry);
    tcpsocket8->flush();
}

void MainWindow::sendDataK9()
{
    QByteArray bytes1 = hexStringToByteArray(dataK);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataK.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket9->write(byteAry);
    tcpsocket9->flush();
}

void MainWindow::sendDataK10()
{

}

void MainWindow::sendDataC1()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket1->write(byteAry);
    tcpsocket1->flush();
}

void MainWindow::sendDataC2()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket2->write(byteAry);
    tcpsocket2->flush();
}

void MainWindow::sendDataC3()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket3->write(byteAry);
    tcpsocket3->flush();
}

void MainWindow::sendDataC4()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket4->write(byteAry);
    tcpsocket4->flush();
}

void MainWindow::sendDataC5()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket5->write(byteAry);
    tcpsocket5->flush();
}

void MainWindow::sendDataC6()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket6->write(byteAry);
    tcpsocket6->flush();
}

void MainWindow::sendDataC7()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket7->write(byteAry);
    tcpsocket7->flush();
}

void MainWindow::sendDataC8()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket8->write(byteAry);
    tcpsocket8->flush();
}

void MainWindow::sendDataC9()
{
    QByteArray bytes1 = hexStringToByteArray(dataC);
    quint16 crc = calculateCRC16(bytes1);
    QString CRC = QString("%1").arg(crc,4,16,QChar('0')).toUpper();
    QByteArray byteAry = QByteArray::fromHex(dataC.toLatin1()+(CRC.mid(2,2)+CRC.mid(0,2)).toLatin1());
    tcpsocket9->write(byteAry);
    tcpsocket9->flush();
}

void MainWindow::sendDataC10()
{

}
